> For the complete documentation index, see [llms.txt](/llms.txt)

# GS2-Key SDK API Reference

Specification of models and API references for GS2-Key SDK for various programming languages



## Models

### Namespace

Namespace

A Namespace allows multiple independent instances of the same service within a single project by separating data spaces and usage contexts.
Each GS2 service is managed on a per-namespace basis. Even when using the same service, if the Namespace differs, the data is treated as a completely independent data space.

Therefore, you must create a Namespace before you can start using each service.



|  | Type | Condition | Required | Default | Value Limits | Description |
| --- | --- | --- | --- | --- | --- | --- |
| namespaceId | string |  | * |  |  ~ 1024 chars | Namespace GRN<br>* Set automatically by the server |
| name | string |  | ✓ |  |  ~ 128 chars | Namespace name<br>Unique Namespace name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). |
| description | string |  |  |  |  ~ 1024 chars | Description |
| logSetting | [LogSetting](#logsetting) |  |  |  |  | Log Output Setting<br>Specifies the GS2-Log Namespace for outputting API request and response logs of encryption key operations. Useful for auditing key usage such as encryption and decryption requests. |
| createdAt | long |  | * | Current time |  | Creation Timestamp<br>Unix time, milliseconds<br>* Set automatically by the server |
| updatedAt | long |  | * | Current time |  | Last Updated Timestamp<br>Unix time, milliseconds<br>* Set automatically by the server |
| revision | long |  |  | 0 | 0 ~ 9223372036854775805 | Revision |

**Related methods:**
describeNamespaces - List Namespaces
createNamespace - Create Namespace
getNamespace - Get Namespace
updateNamespace - Update Namespace
deleteNamespace - Delete Namespace




---

### LogSetting

Log Output Setting

Log Output Setting defines how log data is exported. This type holds the GS2-Log Namespace identifier (Namespace ID), which is used to export log data.
Specify the GS2-Log Namespace where log data is collected and stored in the GRN format for the Log Namespace ID (loggingNamespaceId).
Configuring this setting ensures that log data for API requests and responses occurring within the specified Namespace is output to the target GS2-Log Namespace.
GS2-Log provides real-time logs that can be used for system monitoring, analysis, debugging, and other operational purposes.



|  | Type | Condition | Required | Default | Value Limits | Description |
| --- | --- | --- | --- | --- | --- | --- |
| loggingNamespaceId | string |  | ✓ |  |  ~ 1024 chars | GS2-Log Namespace GRN to output logs<br>Must be specified in GRN format starting with "grn:gs2:". |

**Related methods:**
createNamespace - Create Namespace
updateNamespace - Update Namespace


**Related models:**
Namespace - Namespace




---

### Key

Encryption Key

The GRN of the Encryption Key to be created here must be specified when encryption processing is required by GS2.
The contents of the specific Encryption Key will not be disclosed outside of GS2, and encryption and decryption can be performed securely.



|  | Type | Condition | Required | Default | Value Limits | Description |
| --- | --- | --- | --- | --- | --- | --- |
| keyId | string |  | * |  |  ~ 1024 chars | Encryption Key GRN<br>* Set automatically by the server |
| name | string |  | ✓ |  |  ~ 128 chars | Encryption Key name<br>Unique Encryption Key name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). |
| description | string |  |  |  |  ~ 1024 chars | Description |
| createdAt | long |  | * | Current time |  | Creation Timestamp<br>Unix time, milliseconds<br>* Set automatically by the server |
| updatedAt | long |  | * | Current time |  | Last Updated Timestamp<br>Unix time, milliseconds<br>* Set automatically by the server |
| revision | long |  |  | 0 | 0 ~ 9223372036854775805 | Revision |

**Related methods:**
describeKeys - List Encryption Keys
createKey - Create Encryption Key
updateKey - Update Encryption Key
getKey - Get Encryption Key
deleteKey - Delete Encryption Key




---

### GitHubApiKey

GitHub API Key

GS2 has several interfaces for uploading files such as master data and GS2-Deploy template files.
For these interfaces, instead of uploading data, GS2 provides an interface to reflect settings from a specific branch or tag in a specific repository on GitHub.

This interface stores the GitHub API Key needed to use this interface.



|  | Type | Condition | Required | Default | Value Limits | Description |
| --- | --- | --- | --- | --- | --- | --- |
| apiKeyId | string |  | * |  |  ~ 1024 chars | GitHub API Key GRN<br>* Set automatically by the server |
| name | string |  | ✓ |  |  ~ 128 chars | GitHub API Key name<br>Unique GitHub API Key name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). |
| description | string |  |  |  |  ~ 1024 chars | Description |
| apiKey | string |  | ✓ |  |  ~ 1024 chars | API Key<br>The GitHub personal access token or fine-grained token used to authenticate API requests when fetching master data or GS2-Deploy templates from GitHub repositories. Stored encrypted and never exposed in API responses. Maximum 1024 characters. |
| encryptionKeyName | string |  | ✓ |  |  ~ 128 chars | Encryption Key name<br>Unique Encryption Key name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). |
| createdAt | long |  | * | Current time |  | Creation Timestamp<br>Unix time, milliseconds<br>* Set automatically by the server |
| updatedAt | long |  | * | Current time |  | Last Updated Timestamp<br>Unix time, milliseconds<br>* Set automatically by the server |
| revision | long |  |  | 0 | 0 ~ 9223372036854775805 | Revision |

**Related methods:**
describeGitHubApiKeys - List GitHub API Keys
createGitHubApiKey - Create GitHub API Key
updateGitHubApiKey - Update GitHub API Key
getGitHubApiKey - Get GitHub API Key
deleteGitHubApiKey - Delete GitHub API Key




---
## Methods

### describeNamespaces

List Namespaces

Retrieves a list of Namespaces that have been created on a per-service basis within the project.
You can use the optional page token to start acquiring data from a specific location in the list.
You can also limit the number of Namespaces to be acquired.



#### Request

|  | Type | Condition | Required | Default | Value Limits | Description |
| --- | --- | --- | --- | --- | --- | --- |
| namePrefix | string |  | |  |  ~ 64 chars | Filter by Namespace name prefix |
| pageToken | string |  | |  |  ~ 1024 chars | Token specifying the position from which to start acquiring data |
| limit | int |  | | 30 | 1 ~ 1000 | Number of data items to retrieve |

#### Result

|  | Type | Description |
| --- | --- | --- |
| items | [List&lt;Namespace&gt;](#namespace) | List of Namespaces |
| nextPageToken | string | Page token to retrieve the rest of the listing |

#### Implementation Example




**Go**
```go

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/key"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := key.Gs2KeyRestClient{
    Session: &session,
}
result, err := client.DescribeNamespaces(
    &key.DescribeNamespacesRequest {
        NamePrefix: nil,
        PageToken: nil,
        Limit: nil,
    }
)
if err != nil {
    panic("error occurred")
}
items := result.Items
nextPageToken := result.NextPageToken

```

**PHP**
```php

use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Key\Gs2KeyRestClient;
use Gs2\Key\Request\DescribeNamespacesRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2KeyRestClient(
    $session
);

try {
    $result = $client->describeNamespaces(
        (new DescribeNamespacesRequest())
            ->withNamePrefix(null)
            ->withPageToken(null)
            ->withLimit(null)
    );
    $items = $result->getItems();
    $nextPageToken = $result->getNextPageToken();
} catch (Gs2Exception $e) {
    exit("error occurred")
}

```

**Java**
```java

import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.key.rest.Gs2KeyRestClient;
import io.gs2.key.request.DescribeNamespacesRequest;
import io.gs2.key.result.DescribeNamespacesResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    )
);
session.connect();
Gs2KeyRestClient client = new Gs2KeyRestClient(session);

try {
    DescribeNamespacesResult result = client.describeNamespaces(
        new DescribeNamespacesRequest()
            .withNamePrefix(null)
            .withPageToken(null)
            .withLimit(null)
    );
    List<Namespace> items = result.getItems();
    String nextPageToken = result.getNextPageToken();
} catch (Gs2Exception e) {
    System.exit(1);
}

```

**C#**
```csharp

using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2KeyRestClient(session);

AsyncResult<Gs2.Gs2Key.Result.DescribeNamespacesResult> asyncResult = null;
yield return client.DescribeNamespaces(
    new Gs2.Gs2Key.Request.DescribeNamespacesRequest()
        .WithNamePrefix(null)
        .WithPageToken(null)
        .WithLimit(null),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var items = result.Items;
var nextPageToken = result.NextPageToken;

```

**TypeScript**
```typescript

import Gs2Core from '@/gs2/core';
import * as Gs2Key from '@/gs2/key';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Key.Gs2KeyRestClient(session);

try {
    const result = await client.describeNamespaces(
        new Gs2Key.DescribeNamespacesRequest()
            .withNamePrefix(null)
            .withPageToken(null)
            .withLimit(null)
    );
    const items = result.getItems();
    const nextPageToken = result.getNextPageToken();
} catch (e) {
    process.exit(1);
}

```

**Python**
```python

from gs2 import core
from gs2 import key

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = key.Gs2KeyRestClient(session)

try:
    result = client.describe_namespaces(
        key.DescribeNamespacesRequest()
            .with_name_prefix(None)
            .with_page_token(None)
            .with_limit(None)
    )
    items = result.items
    next_page_token = result.next_page_token
except core.Gs2Exception as e:
    exit(1)


```

**GS2-Script**
```lua

client = gs2('key')

api_result = client.describe_namespaces({
    namePrefix=nil,
    pageToken=nil,
    limit=nil,
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['errorMessage'])
end

result = api_result.result
items = result.items;
nextPageToken = result.nextPageToken;

```

**GS2-Script(Async)**
```lua

client = gs2('key')

api_result_handler = client.describe_namespaces_async({
    namePrefix=nil,
    pageToken=nil,
    limit=nil,
})

api_result = api_result_handler()  -- Call the handler to get the result

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['errorMessage'])
end

result = api_result.result
items = result.items;
nextPageToken = result.nextPageToken;

```




---

### createNamespace

Create Namespace

Creates a new key management Namespace.
The Namespace serves as a container for encryption keys and GitHub API keys.
Encryption keys within the Namespace are used for data encryption/decryption across GS2 services, and GitHub API keys are used for master data operations from GitHub repositories.



#### Request

|  | Type | Condition | Required | Default | Value Limits | Description |
| --- | --- | --- | --- | --- | --- | --- |
| name | string |  | ✓|  |  ~ 128 chars | Namespace name<br>Unique Namespace name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). |
| description | string |  | |  |  ~ 1024 chars | Description |
| logSetting | [LogSetting](#logsetting) |  | |  |  | Log Output Setting<br>Specifies the GS2-Log Namespace for outputting API request and response logs of encryption key operations. Useful for auditing key usage such as encryption and decryption requests. |

#### Result

|  | Type | Description |
| --- | --- | --- |
| item | [Namespace](#namespace) | Namespace created |

#### Implementation Example




**Go**
```go

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/key"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := key.Gs2KeyRestClient{
    Session: &session,
}
result, err := client.CreateNamespace(
    &key.CreateNamespaceRequest {
        Name: pointy.String("namespace-0001"),
        Description: nil,
        LogSetting: &key.LogSetting{
            LoggingNamespaceId: pointy.String("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"),
        },
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item

```

**PHP**
```php

use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Key\Gs2KeyRestClient;
use Gs2\Key\Request\CreateNamespaceRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2KeyRestClient(
    $session
);

try {
    $result = $client->createNamespace(
        (new CreateNamespaceRequest())
            ->withName("namespace-0001")
            ->withDescription(null)
            ->withLogSetting((new \Gs2\Key\Model\LogSetting())
                ->withLoggingNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"))
    );
    $item = $result->getItem();
} catch (Gs2Exception $e) {
    exit("error occurred")
}

```

**Java**
```java

import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.key.rest.Gs2KeyRestClient;
import io.gs2.key.request.CreateNamespaceRequest;
import io.gs2.key.result.CreateNamespaceResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    )
);
session.connect();
Gs2KeyRestClient client = new Gs2KeyRestClient(session);

try {
    CreateNamespaceResult result = client.createNamespace(
        new CreateNamespaceRequest()
            .withName("namespace-0001")
            .withDescription(null)
            .withLogSetting(new io.gs2.key.model.LogSetting()
                .withLoggingNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"))
    );
    Namespace item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}

```

**C#**
```csharp

using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2KeyRestClient(session);

AsyncResult<Gs2.Gs2Key.Result.CreateNamespaceResult> asyncResult = null;
yield return client.CreateNamespace(
    new Gs2.Gs2Key.Request.CreateNamespaceRequest()
        .WithName("namespace-0001")
        .WithDescription(null)
        .WithLogSetting(new Gs2.Gs2Key.Model.LogSetting()
            .WithLoggingNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001")),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;

```

**TypeScript**
```typescript

import Gs2Core from '@/gs2/core';
import * as Gs2Key from '@/gs2/key';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Key.Gs2KeyRestClient(session);

try {
    const result = await client.createNamespace(
        new Gs2Key.CreateNamespaceRequest()
            .withName("namespace-0001")
            .withDescription(null)
            .withLogSetting(new Gs2Key.model.LogSetting()
                .withLoggingNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"))
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}

```

**Python**
```python

from gs2 import core
from gs2 import key

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = key.Gs2KeyRestClient(session)

try:
    result = client.create_namespace(
        key.CreateNamespaceRequest()
            .with_name('namespace-0001')
            .with_description(None)
            .with_log_setting(
                key.LogSetting()
                    .with_logging_namespace_id('grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001'))
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)


```

**GS2-Script**
```lua

client = gs2('key')

api_result = client.create_namespace({
    name="namespace-0001",
    description=nil,
    logSetting={
        loggingNamespaceId="grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001",
    },
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['errorMessage'])
end

result = api_result.result
item = result.item;

```

**GS2-Script(Async)**
```lua

client = gs2('key')

api_result_handler = client.create_namespace_async({
    name="namespace-0001",
    description=nil,
    logSetting={
        loggingNamespaceId="grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001",
    },
})

api_result = api_result_handler()  -- Call the handler to get the result

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['errorMessage'])
end

result = api_result.result
item = result.item;

```




---

### getNamespaceStatus

Get Namespace Status

Get the current status of the specified Namespace.
This includes whether the Namespace is active, pending, or in some other state.



#### Request

|  | Type | Condition | Required | Default | Value Limits | Description |
| --- | --- | --- | --- | --- | --- | --- |
| namespaceName | string |  | ✓|  |  ~ 128 chars | Namespace name<br>Unique Namespace name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). |

#### Result

|  | Type | Description |
| --- | --- | --- |
| status | string |  |

#### Implementation Example




**Go**
```go

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/key"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := key.Gs2KeyRestClient{
    Session: &session,
}
result, err := client.GetNamespaceStatus(
    &key.GetNamespaceStatusRequest {
        NamespaceName: pointy.String("namespace-0001"),
    }
)
if err != nil {
    panic("error occurred")
}
status := result.Status

```

**PHP**
```php

use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Key\Gs2KeyRestClient;
use Gs2\Key\Request\GetNamespaceStatusRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2KeyRestClient(
    $session
);

try {
    $result = $client->getNamespaceStatus(
        (new GetNamespaceStatusRequest())
            ->withNamespaceName("namespace-0001")
    );
    $status = $result->getStatus();
} catch (Gs2Exception $e) {
    exit("error occurred")
}

```

**Java**
```java

import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.key.rest.Gs2KeyRestClient;
import io.gs2.key.request.GetNamespaceStatusRequest;
import io.gs2.key.result.GetNamespaceStatusResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    )
);
session.connect();
Gs2KeyRestClient client = new Gs2KeyRestClient(session);

try {
    GetNamespaceStatusResult result = client.getNamespaceStatus(
        new GetNamespaceStatusRequest()
            .withNamespaceName("namespace-0001")
    );
    String status = result.getStatus();
} catch (Gs2Exception e) {
    System.exit(1);
}

```

**C#**
```csharp

using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2KeyRestClient(session);

AsyncResult<Gs2.Gs2Key.Result.GetNamespaceStatusResult> asyncResult = null;
yield return client.GetNamespaceStatus(
    new Gs2.Gs2Key.Request.GetNamespaceStatusRequest()
        .WithNamespaceName("namespace-0001"),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var status = result.Status;

```

**TypeScript**
```typescript

import Gs2Core from '@/gs2/core';
import * as Gs2Key from '@/gs2/key';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Key.Gs2KeyRestClient(session);

try {
    const result = await client.getNamespaceStatus(
        new Gs2Key.GetNamespaceStatusRequest()
            .withNamespaceName("namespace-0001")
    );
    const status = result.getStatus();
} catch (e) {
    process.exit(1);
}

```

**Python**
```python

from gs2 import core
from gs2 import key

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = key.Gs2KeyRestClient(session)

try:
    result = client.get_namespace_status(
        key.GetNamespaceStatusRequest()
            .with_namespace_name('namespace-0001')
    )
    status = result.status
except core.Gs2Exception as e:
    exit(1)


```

**GS2-Script**
```lua

client = gs2('key')

api_result = client.get_namespace_status({
    namespaceName="namespace-0001",
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['errorMessage'])
end

result = api_result.result
status = result.status;

```

**GS2-Script(Async)**
```lua

client = gs2('key')

api_result_handler = client.get_namespace_status_async({
    namespaceName="namespace-0001",
})

api_result = api_result_handler()  -- Call the handler to get the result

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['errorMessage'])
end

result = api_result.result
status = result.status;

```




---

### getNamespace

Get Namespace

Get detailed information about the specified Namespace.
This includes the name, description, and other settings of the Namespace.



#### Request

|  | Type | Condition | Required | Default | Value Limits | Description |
| --- | --- | --- | --- | --- | --- | --- |
| namespaceName | string |  | ✓|  |  ~ 128 chars | Namespace name<br>Unique Namespace name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). |

#### Result

|  | Type | Description |
| --- | --- | --- |
| item | [Namespace](#namespace) | Namespace |

#### Implementation Example




**Go**
```go

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/key"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := key.Gs2KeyRestClient{
    Session: &session,
}
result, err := client.GetNamespace(
    &key.GetNamespaceRequest {
        NamespaceName: pointy.String("namespace-0001"),
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item

```

**PHP**
```php

use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Key\Gs2KeyRestClient;
use Gs2\Key\Request\GetNamespaceRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2KeyRestClient(
    $session
);

try {
    $result = $client->getNamespace(
        (new GetNamespaceRequest())
            ->withNamespaceName("namespace-0001")
    );
    $item = $result->getItem();
} catch (Gs2Exception $e) {
    exit("error occurred")
}

```

**Java**
```java

import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.key.rest.Gs2KeyRestClient;
import io.gs2.key.request.GetNamespaceRequest;
import io.gs2.key.result.GetNamespaceResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    )
);
session.connect();
Gs2KeyRestClient client = new Gs2KeyRestClient(session);

try {
    GetNamespaceResult result = client.getNamespace(
        new GetNamespaceRequest()
            .withNamespaceName("namespace-0001")
    );
    Namespace item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}

```

**C#**
```csharp

using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2KeyRestClient(session);

AsyncResult<Gs2.Gs2Key.Result.GetNamespaceResult> asyncResult = null;
yield return client.GetNamespace(
    new Gs2.Gs2Key.Request.GetNamespaceRequest()
        .WithNamespaceName("namespace-0001"),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;

```

**TypeScript**
```typescript

import Gs2Core from '@/gs2/core';
import * as Gs2Key from '@/gs2/key';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Key.Gs2KeyRestClient(session);

try {
    const result = await client.getNamespace(
        new Gs2Key.GetNamespaceRequest()
            .withNamespaceName("namespace-0001")
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}

```

**Python**
```python

from gs2 import core
from gs2 import key

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = key.Gs2KeyRestClient(session)

try:
    result = client.get_namespace(
        key.GetNamespaceRequest()
            .with_namespace_name('namespace-0001')
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)


```

**GS2-Script**
```lua

client = gs2('key')

api_result = client.get_namespace({
    namespaceName="namespace-0001",
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['errorMessage'])
end

result = api_result.result
item = result.item;

```

**GS2-Script(Async)**
```lua

client = gs2('key')

api_result_handler = client.get_namespace_async({
    namespaceName="namespace-0001",
})

api_result = api_result_handler()  -- Call the handler to get the result

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['errorMessage'])
end

result = api_result.result
item = result.item;

```




---

### updateNamespace

Update Namespace

Updates the settings of the specified key management Namespace.
You can change the description and log settings.



#### Request

|  | Type | Condition | Required | Default | Value Limits | Description |
| --- | --- | --- | --- | --- | --- | --- |
| namespaceName | string |  | ✓|  |  ~ 128 chars | Namespace name<br>Unique Namespace name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). |
| description | string |  | |  |  ~ 1024 chars | Description |
| logSetting | [LogSetting](#logsetting) |  | |  |  | Log Output Setting<br>Specifies the GS2-Log Namespace for outputting API request and response logs of encryption key operations. Useful for auditing key usage such as encryption and decryption requests. |

#### Result

|  | Type | Description |
| --- | --- | --- |
| item | [Namespace](#namespace) | Namespace updated |

#### Implementation Example




**Go**
```go

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/key"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := key.Gs2KeyRestClient{
    Session: &session,
}
result, err := client.UpdateNamespace(
    &key.UpdateNamespaceRequest {
        NamespaceName: pointy.String("namespace-0001"),
        Description: pointy.String("description1"),
        LogSetting: &key.LogSetting{
            LoggingNamespaceId: pointy.String("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"),
        },
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item

```

**PHP**
```php

use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Key\Gs2KeyRestClient;
use Gs2\Key\Request\UpdateNamespaceRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2KeyRestClient(
    $session
);

try {
    $result = $client->updateNamespace(
        (new UpdateNamespaceRequest())
            ->withNamespaceName("namespace-0001")
            ->withDescription("description1")
            ->withLogSetting((new \Gs2\Key\Model\LogSetting())
                ->withLoggingNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"))
    );
    $item = $result->getItem();
} catch (Gs2Exception $e) {
    exit("error occurred")
}

```

**Java**
```java

import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.key.rest.Gs2KeyRestClient;
import io.gs2.key.request.UpdateNamespaceRequest;
import io.gs2.key.result.UpdateNamespaceResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    )
);
session.connect();
Gs2KeyRestClient client = new Gs2KeyRestClient(session);

try {
    UpdateNamespaceResult result = client.updateNamespace(
        new UpdateNamespaceRequest()
            .withNamespaceName("namespace-0001")
            .withDescription("description1")
            .withLogSetting(new io.gs2.key.model.LogSetting()
                .withLoggingNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"))
    );
    Namespace item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}

```

**C#**
```csharp

using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2KeyRestClient(session);

AsyncResult<Gs2.Gs2Key.Result.UpdateNamespaceResult> asyncResult = null;
yield return client.UpdateNamespace(
    new Gs2.Gs2Key.Request.UpdateNamespaceRequest()
        .WithNamespaceName("namespace-0001")
        .WithDescription("description1")
        .WithLogSetting(new Gs2.Gs2Key.Model.LogSetting()
            .WithLoggingNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001")),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;

```

**TypeScript**
```typescript

import Gs2Core from '@/gs2/core';
import * as Gs2Key from '@/gs2/key';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Key.Gs2KeyRestClient(session);

try {
    const result = await client.updateNamespace(
        new Gs2Key.UpdateNamespaceRequest()
            .withNamespaceName("namespace-0001")
            .withDescription("description1")
            .withLogSetting(new Gs2Key.model.LogSetting()
                .withLoggingNamespaceId("grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001"))
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}

```

**Python**
```python

from gs2 import core
from gs2 import key

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = key.Gs2KeyRestClient(session)

try:
    result = client.update_namespace(
        key.UpdateNamespaceRequest()
            .with_namespace_name('namespace-0001')
            .with_description('description1')
            .with_log_setting(
                key.LogSetting()
                    .with_logging_namespace_id('grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001'))
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)


```

**GS2-Script**
```lua

client = gs2('key')

api_result = client.update_namespace({
    namespaceName="namespace-0001",
    description="description1",
    logSetting={
        loggingNamespaceId="grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001",
    },
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['errorMessage'])
end

result = api_result.result
item = result.item;

```

**GS2-Script(Async)**
```lua

client = gs2('key')

api_result_handler = client.update_namespace_async({
    namespaceName="namespace-0001",
    description="description1",
    logSetting={
        loggingNamespaceId="grn:gs2:ap-northeast-1:YourOwnerId:log:namespace-0001",
    },
})

api_result = api_result_handler()  -- Call the handler to get the result

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['errorMessage'])
end

result = api_result.result
item = result.item;

```




---

### deleteNamespace

Delete Namespace

Delete the specified Namespace.
This operation is irreversible and all data associated with the deleted Namespace will be lost.



#### Request

|  | Type | Condition | Required | Default | Value Limits | Description |
| --- | --- | --- | --- | --- | --- | --- |
| namespaceName | string |  | ✓|  |  ~ 128 chars | Namespace name<br>Unique Namespace name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). |

#### Result

|  | Type | Description |
| --- | --- | --- |
| item | [Namespace](#namespace) | Deleted Namespace |

#### Implementation Example




**Go**
```go

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/key"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := key.Gs2KeyRestClient{
    Session: &session,
}
result, err := client.DeleteNamespace(
    &key.DeleteNamespaceRequest {
        NamespaceName: pointy.String("namespace-0001"),
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item

```

**PHP**
```php

use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Key\Gs2KeyRestClient;
use Gs2\Key\Request\DeleteNamespaceRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2KeyRestClient(
    $session
);

try {
    $result = $client->deleteNamespace(
        (new DeleteNamespaceRequest())
            ->withNamespaceName("namespace-0001")
    );
    $item = $result->getItem();
} catch (Gs2Exception $e) {
    exit("error occurred")
}

```

**Java**
```java

import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.key.rest.Gs2KeyRestClient;
import io.gs2.key.request.DeleteNamespaceRequest;
import io.gs2.key.result.DeleteNamespaceResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    )
);
session.connect();
Gs2KeyRestClient client = new Gs2KeyRestClient(session);

try {
    DeleteNamespaceResult result = client.deleteNamespace(
        new DeleteNamespaceRequest()
            .withNamespaceName("namespace-0001")
    );
    Namespace item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}

```

**C#**
```csharp

using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2KeyRestClient(session);

AsyncResult<Gs2.Gs2Key.Result.DeleteNamespaceResult> asyncResult = null;
yield return client.DeleteNamespace(
    new Gs2.Gs2Key.Request.DeleteNamespaceRequest()
        .WithNamespaceName("namespace-0001"),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;

```

**TypeScript**
```typescript

import Gs2Core from '@/gs2/core';
import * as Gs2Key from '@/gs2/key';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Key.Gs2KeyRestClient(session);

try {
    const result = await client.deleteNamespace(
        new Gs2Key.DeleteNamespaceRequest()
            .withNamespaceName("namespace-0001")
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}

```

**Python**
```python

from gs2 import core
from gs2 import key

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = key.Gs2KeyRestClient(session)

try:
    result = client.delete_namespace(
        key.DeleteNamespaceRequest()
            .with_namespace_name('namespace-0001')
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)


```

**GS2-Script**
```lua

client = gs2('key')

api_result = client.delete_namespace({
    namespaceName="namespace-0001",
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['errorMessage'])
end

result = api_result.result
item = result.item;

```

**GS2-Script(Async)**
```lua

client = gs2('key')

api_result_handler = client.delete_namespace_async({
    namespaceName="namespace-0001",
})

api_result = api_result_handler()  -- Call the handler to get the result

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['errorMessage'])
end

result = api_result.result
item = result.item;

```




---

### getServiceVersion

Get Microservice Version



#### Request

Request parameters: None

#### Result

|  | Type | Description |
| --- | --- | --- |
| item | string | Version |

#### Implementation Example




**Go**
```go

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/key"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := key.Gs2KeyRestClient{
    Session: &session,
}
result, err := client.GetServiceVersion(
    &key.GetServiceVersionRequest {
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item

```

**PHP**
```php

use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Key\Gs2KeyRestClient;
use Gs2\Key\Request\GetServiceVersionRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2KeyRestClient(
    $session
);

try {
    $result = $client->getServiceVersion(
        (new GetServiceVersionRequest())
    );
    $item = $result->getItem();
} catch (Gs2Exception $e) {
    exit("error occurred")
}

```

**Java**
```java

import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.key.rest.Gs2KeyRestClient;
import io.gs2.key.request.GetServiceVersionRequest;
import io.gs2.key.result.GetServiceVersionResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    )
);
session.connect();
Gs2KeyRestClient client = new Gs2KeyRestClient(session);

try {
    GetServiceVersionResult result = client.getServiceVersion(
        new GetServiceVersionRequest()
    );
    String item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}

```

**C#**
```csharp

using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2KeyRestClient(session);

AsyncResult<Gs2.Gs2Key.Result.GetServiceVersionResult> asyncResult = null;
yield return client.GetServiceVersion(
    new Gs2.Gs2Key.Request.GetServiceVersionRequest(),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;

```

**TypeScript**
```typescript

import Gs2Core from '@/gs2/core';
import * as Gs2Key from '@/gs2/key';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Key.Gs2KeyRestClient(session);

try {
    const result = await client.getServiceVersion(
        new Gs2Key.GetServiceVersionRequest()
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}

```

**Python**
```python

from gs2 import core
from gs2 import key

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = key.Gs2KeyRestClient(session)

try:
    result = client.get_service_version(
        key.GetServiceVersionRequest()
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)


```

**GS2-Script**
```lua

client = gs2('key')

api_result = client.get_service_version({
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['errorMessage'])
end

result = api_result.result
item = result.item;

```

**GS2-Script(Async)**
```lua

client = gs2('key')

api_result_handler = client.get_service_version_async({
})

api_result = api_result_handler()  -- Call the handler to get the result

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['errorMessage'])
end

result = api_result.result
item = result.item;

```




---

### describeKeys

List Encryption Keys

Retrieves a paginated list of encryption keys in the specified Namespace.
Encryption keys are used for encrypting and decrypting data across GS2 services, such as securing transactions and protecting sensitive configuration.



#### Request

|  | Type | Condition | Required | Default | Value Limits | Description |
| --- | --- | --- | --- | --- | --- | --- |
| namespaceName | string |  | ✓|  |  ~ 128 chars | Namespace name<br>Unique Namespace name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). |
| namePrefix | string |  | |  |  ~ 64 chars | Filter by Encryption Key name prefix |
| pageToken | string |  | |  |  ~ 1024 chars | Token specifying the position from which to start acquiring data |
| limit | int |  | | 30 | 1 ~ 1000 | Number of data items to retrieve |

#### Result

|  | Type | Description |
| --- | --- | --- |
| items | [List&lt;Key&gt;](#key) | List of Encryption Keys |
| nextPageToken | string | Page token to retrieve the rest of the listing |

#### Implementation Example




**Go**
```go

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/key"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := key.Gs2KeyRestClient{
    Session: &session,
}
result, err := client.DescribeKeys(
    &key.DescribeKeysRequest {
        NamespaceName: pointy.String("namespace-0001"),
        NamePrefix: nil,
        PageToken: nil,
        Limit: nil,
    }
)
if err != nil {
    panic("error occurred")
}
items := result.Items
nextPageToken := result.NextPageToken

```

**PHP**
```php

use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Key\Gs2KeyRestClient;
use Gs2\Key\Request\DescribeKeysRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2KeyRestClient(
    $session
);

try {
    $result = $client->describeKeys(
        (new DescribeKeysRequest())
            ->withNamespaceName("namespace-0001")
            ->withNamePrefix(null)
            ->withPageToken(null)
            ->withLimit(null)
    );
    $items = $result->getItems();
    $nextPageToken = $result->getNextPageToken();
} catch (Gs2Exception $e) {
    exit("error occurred")
}

```

**Java**
```java

import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.key.rest.Gs2KeyRestClient;
import io.gs2.key.request.DescribeKeysRequest;
import io.gs2.key.result.DescribeKeysResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    )
);
session.connect();
Gs2KeyRestClient client = new Gs2KeyRestClient(session);

try {
    DescribeKeysResult result = client.describeKeys(
        new DescribeKeysRequest()
            .withNamespaceName("namespace-0001")
            .withNamePrefix(null)
            .withPageToken(null)
            .withLimit(null)
    );
    List<Key> items = result.getItems();
    String nextPageToken = result.getNextPageToken();
} catch (Gs2Exception e) {
    System.exit(1);
}

```

**C#**
```csharp

using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2KeyRestClient(session);

AsyncResult<Gs2.Gs2Key.Result.DescribeKeysResult> asyncResult = null;
yield return client.DescribeKeys(
    new Gs2.Gs2Key.Request.DescribeKeysRequest()
        .WithNamespaceName("namespace-0001")
        .WithNamePrefix(null)
        .WithPageToken(null)
        .WithLimit(null),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var items = result.Items;
var nextPageToken = result.NextPageToken;

```

**TypeScript**
```typescript

import Gs2Core from '@/gs2/core';
import * as Gs2Key from '@/gs2/key';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Key.Gs2KeyRestClient(session);

try {
    const result = await client.describeKeys(
        new Gs2Key.DescribeKeysRequest()
            .withNamespaceName("namespace-0001")
            .withNamePrefix(null)
            .withPageToken(null)
            .withLimit(null)
    );
    const items = result.getItems();
    const nextPageToken = result.getNextPageToken();
} catch (e) {
    process.exit(1);
}

```

**Python**
```python

from gs2 import core
from gs2 import key

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = key.Gs2KeyRestClient(session)

try:
    result = client.describe_keys(
        key.DescribeKeysRequest()
            .with_namespace_name('namespace-0001')
            .with_name_prefix(None)
            .with_page_token(None)
            .with_limit(None)
    )
    items = result.items
    next_page_token = result.next_page_token
except core.Gs2Exception as e:
    exit(1)


```

**GS2-Script**
```lua

client = gs2('key')

api_result = client.describe_keys({
    namespaceName="namespace-0001",
    namePrefix=nil,
    pageToken=nil,
    limit=nil,
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['errorMessage'])
end

result = api_result.result
items = result.items;
nextPageToken = result.nextPageToken;

```

**GS2-Script(Async)**
```lua

client = gs2('key')

api_result_handler = client.describe_keys_async({
    namespaceName="namespace-0001",
    namePrefix=nil,
    pageToken=nil,
    limit=nil,
})

api_result = api_result_handler()  -- Call the handler to get the result

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['errorMessage'])
end

result = api_result.result
items = result.items;
nextPageToken = result.nextPageToken;

```




---

### createKey

Create Encryption Key

Creates a new encryption key with an automatically generated random secret.
The generated key can be used for encrypting and decrypting data via the Encrypt/Decrypt APIs.
The secret itself is never exposed through the API; only the key metadata (name, description, GRN) is returned.



#### Request

|  | Type | Condition | Required | Default | Value Limits | Description |
| --- | --- | --- | --- | --- | --- | --- |
| namespaceName | string |  | ✓|  |  ~ 128 chars | Namespace name<br>Unique Namespace name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). |
| name | string |  | ✓|  |  ~ 128 chars | Encryption Key name<br>Unique Encryption Key name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). |
| description | string |  | |  |  ~ 1024 chars | Description |

#### Result

|  | Type | Description |
| --- | --- | --- |
| item | [Key](#key) | Encryption Key created |

#### Implementation Example




**Go**
```go

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/key"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := key.Gs2KeyRestClient{
    Session: &session,
}
result, err := client.CreateKey(
    &key.CreateKeyRequest {
        NamespaceName: pointy.String("namespace-0001"),
        Name: pointy.String("key-0001"),
        Description: nil,
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item

```

**PHP**
```php

use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Key\Gs2KeyRestClient;
use Gs2\Key\Request\CreateKeyRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2KeyRestClient(
    $session
);

try {
    $result = $client->createKey(
        (new CreateKeyRequest())
            ->withNamespaceName("namespace-0001")
            ->withName("key-0001")
            ->withDescription(null)
    );
    $item = $result->getItem();
} catch (Gs2Exception $e) {
    exit("error occurred")
}

```

**Java**
```java

import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.key.rest.Gs2KeyRestClient;
import io.gs2.key.request.CreateKeyRequest;
import io.gs2.key.result.CreateKeyResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    )
);
session.connect();
Gs2KeyRestClient client = new Gs2KeyRestClient(session);

try {
    CreateKeyResult result = client.createKey(
        new CreateKeyRequest()
            .withNamespaceName("namespace-0001")
            .withName("key-0001")
            .withDescription(null)
    );
    Key item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}

```

**C#**
```csharp

using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2KeyRestClient(session);

AsyncResult<Gs2.Gs2Key.Result.CreateKeyResult> asyncResult = null;
yield return client.CreateKey(
    new Gs2.Gs2Key.Request.CreateKeyRequest()
        .WithNamespaceName("namespace-0001")
        .WithName("key-0001")
        .WithDescription(null),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;

```

**TypeScript**
```typescript

import Gs2Core from '@/gs2/core';
import * as Gs2Key from '@/gs2/key';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Key.Gs2KeyRestClient(session);

try {
    const result = await client.createKey(
        new Gs2Key.CreateKeyRequest()
            .withNamespaceName("namespace-0001")
            .withName("key-0001")
            .withDescription(null)
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}

```

**Python**
```python

from gs2 import core
from gs2 import key

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = key.Gs2KeyRestClient(session)

try:
    result = client.create_key(
        key.CreateKeyRequest()
            .with_namespace_name('namespace-0001')
            .with_name('key-0001')
            .with_description(None)
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)


```

**GS2-Script**
```lua

client = gs2('key')

api_result = client.create_key({
    namespaceName="namespace-0001",
    name="key-0001",
    description=nil,
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['errorMessage'])
end

result = api_result.result
item = result.item;

```

**GS2-Script(Async)**
```lua

client = gs2('key')

api_result_handler = client.create_key_async({
    namespaceName="namespace-0001",
    name="key-0001",
    description=nil,
})

api_result = api_result_handler()  -- Call the handler to get the result

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['errorMessage'])
end

result = api_result.result
item = result.item;

```




---

### updateKey

Update Encryption Key

Updates the description of an existing encryption key.
The encryption secret is not changed; only metadata can be updated.



#### Request

|  | Type | Condition | Required | Default | Value Limits | Description |
| --- | --- | --- | --- | --- | --- | --- |
| namespaceName | string |  | ✓|  |  ~ 128 chars | Namespace name<br>Unique Namespace name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). |
| keyName | string |  | ✓|  |  ~ 128 chars | Encryption Key name<br>Unique Encryption Key name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). |
| description | string |  | |  |  ~ 1024 chars | Description |

#### Result

|  | Type | Description |
| --- | --- | --- |
| item | [Key](#key) | Encryption Key updated |

#### Implementation Example




**Go**
```go

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/key"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := key.Gs2KeyRestClient{
    Session: &session,
}
result, err := client.UpdateKey(
    &key.UpdateKeyRequest {
        NamespaceName: pointy.String("namespace-0001"),
        KeyName: pointy.String("key-0001"),
        Description: pointy.String("description1"),
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item

```

**PHP**
```php

use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Key\Gs2KeyRestClient;
use Gs2\Key\Request\UpdateKeyRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2KeyRestClient(
    $session
);

try {
    $result = $client->updateKey(
        (new UpdateKeyRequest())
            ->withNamespaceName("namespace-0001")
            ->withKeyName("key-0001")
            ->withDescription("description1")
    );
    $item = $result->getItem();
} catch (Gs2Exception $e) {
    exit("error occurred")
}

```

**Java**
```java

import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.key.rest.Gs2KeyRestClient;
import io.gs2.key.request.UpdateKeyRequest;
import io.gs2.key.result.UpdateKeyResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    )
);
session.connect();
Gs2KeyRestClient client = new Gs2KeyRestClient(session);

try {
    UpdateKeyResult result = client.updateKey(
        new UpdateKeyRequest()
            .withNamespaceName("namespace-0001")
            .withKeyName("key-0001")
            .withDescription("description1")
    );
    Key item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}

```

**C#**
```csharp

using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2KeyRestClient(session);

AsyncResult<Gs2.Gs2Key.Result.UpdateKeyResult> asyncResult = null;
yield return client.UpdateKey(
    new Gs2.Gs2Key.Request.UpdateKeyRequest()
        .WithNamespaceName("namespace-0001")
        .WithKeyName("key-0001")
        .WithDescription("description1"),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;

```

**TypeScript**
```typescript

import Gs2Core from '@/gs2/core';
import * as Gs2Key from '@/gs2/key';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Key.Gs2KeyRestClient(session);

try {
    const result = await client.updateKey(
        new Gs2Key.UpdateKeyRequest()
            .withNamespaceName("namespace-0001")
            .withKeyName("key-0001")
            .withDescription("description1")
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}

```

**Python**
```python

from gs2 import core
from gs2 import key

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = key.Gs2KeyRestClient(session)

try:
    result = client.update_key(
        key.UpdateKeyRequest()
            .with_namespace_name('namespace-0001')
            .with_key_name('key-0001')
            .with_description('description1')
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)


```

**GS2-Script**
```lua

client = gs2('key')

api_result = client.update_key({
    namespaceName="namespace-0001",
    keyName="key-0001",
    description="description1",
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['errorMessage'])
end

result = api_result.result
item = result.item;

```

**GS2-Script(Async)**
```lua

client = gs2('key')

api_result_handler = client.update_key_async({
    namespaceName="namespace-0001",
    keyName="key-0001",
    description="description1",
})

api_result = api_result_handler()  -- Call the handler to get the result

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['errorMessage'])
end

result = api_result.result
item = result.item;

```




---

### getKey

Get Encryption Key

Retrieves the metadata of a specific encryption key.
The encryption secret is not included in the response for security reasons.



#### Request

|  | Type | Condition | Required | Default | Value Limits | Description |
| --- | --- | --- | --- | --- | --- | --- |
| namespaceName | string |  | ✓|  |  ~ 128 chars | Namespace name<br>Unique Namespace name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). |
| keyName | string |  | ✓|  |  ~ 128 chars | Encryption Key name<br>Unique Encryption Key name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). |

#### Result

|  | Type | Description |
| --- | --- | --- |
| item | [Key](#key) | Encryption Key |

#### Implementation Example




**Go**
```go

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/key"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := key.Gs2KeyRestClient{
    Session: &session,
}
result, err := client.GetKey(
    &key.GetKeyRequest {
        NamespaceName: pointy.String("namespace-0001"),
        KeyName: pointy.String("key-0001"),
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item

```

**PHP**
```php

use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Key\Gs2KeyRestClient;
use Gs2\Key\Request\GetKeyRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2KeyRestClient(
    $session
);

try {
    $result = $client->getKey(
        (new GetKeyRequest())
            ->withNamespaceName("namespace-0001")
            ->withKeyName("key-0001")
    );
    $item = $result->getItem();
} catch (Gs2Exception $e) {
    exit("error occurred")
}

```

**Java**
```java

import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.key.rest.Gs2KeyRestClient;
import io.gs2.key.request.GetKeyRequest;
import io.gs2.key.result.GetKeyResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    )
);
session.connect();
Gs2KeyRestClient client = new Gs2KeyRestClient(session);

try {
    GetKeyResult result = client.getKey(
        new GetKeyRequest()
            .withNamespaceName("namespace-0001")
            .withKeyName("key-0001")
    );
    Key item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}

```

**C#**
```csharp

using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2KeyRestClient(session);

AsyncResult<Gs2.Gs2Key.Result.GetKeyResult> asyncResult = null;
yield return client.GetKey(
    new Gs2.Gs2Key.Request.GetKeyRequest()
        .WithNamespaceName("namespace-0001")
        .WithKeyName("key-0001"),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;

```

**TypeScript**
```typescript

import Gs2Core from '@/gs2/core';
import * as Gs2Key from '@/gs2/key';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Key.Gs2KeyRestClient(session);

try {
    const result = await client.getKey(
        new Gs2Key.GetKeyRequest()
            .withNamespaceName("namespace-0001")
            .withKeyName("key-0001")
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}

```

**Python**
```python

from gs2 import core
from gs2 import key

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = key.Gs2KeyRestClient(session)

try:
    result = client.get_key(
        key.GetKeyRequest()
            .with_namespace_name('namespace-0001')
            .with_key_name('key-0001')
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)


```

**GS2-Script**
```lua

client = gs2('key')

api_result = client.get_key({
    namespaceName="namespace-0001",
    keyName="key-0001",
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['errorMessage'])
end

result = api_result.result
item = result.item;

```

**GS2-Script(Async)**
```lua

client = gs2('key')

api_result_handler = client.get_key_async({
    namespaceName="namespace-0001",
    keyName="key-0001",
})

api_result = api_result_handler()  -- Call the handler to get the result

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['errorMessage'])
end

result = api_result.result
item = result.item;

```




---

### deleteKey

Delete Encryption Key

Deletes the specified encryption key and its secret permanently.
Data previously encrypted with this key will no longer be decryptable after deletion.
Ensure that no other services depend on this key before deleting it.



#### Request

|  | Type | Condition | Required | Default | Value Limits | Description |
| --- | --- | --- | --- | --- | --- | --- |
| namespaceName | string |  | ✓|  |  ~ 128 chars | Namespace name<br>Unique Namespace name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). |
| keyName | string |  | ✓|  |  ~ 128 chars | Encryption Key name<br>Unique Encryption Key name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). |

#### Result

|  | Type | Description |
| --- | --- | --- |
| item | [Key](#key) | Encryption Key deleted |

#### Implementation Example




**Go**
```go

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/key"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := key.Gs2KeyRestClient{
    Session: &session,
}
result, err := client.DeleteKey(
    &key.DeleteKeyRequest {
        NamespaceName: pointy.String("namespace-0001"),
        KeyName: pointy.String("key-0001"),
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item

```

**PHP**
```php

use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Key\Gs2KeyRestClient;
use Gs2\Key\Request\DeleteKeyRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2KeyRestClient(
    $session
);

try {
    $result = $client->deleteKey(
        (new DeleteKeyRequest())
            ->withNamespaceName("namespace-0001")
            ->withKeyName("key-0001")
    );
    $item = $result->getItem();
} catch (Gs2Exception $e) {
    exit("error occurred")
}

```

**Java**
```java

import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.key.rest.Gs2KeyRestClient;
import io.gs2.key.request.DeleteKeyRequest;
import io.gs2.key.result.DeleteKeyResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    )
);
session.connect();
Gs2KeyRestClient client = new Gs2KeyRestClient(session);

try {
    DeleteKeyResult result = client.deleteKey(
        new DeleteKeyRequest()
            .withNamespaceName("namespace-0001")
            .withKeyName("key-0001")
    );
    Key item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}

```

**C#**
```csharp

using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2KeyRestClient(session);

AsyncResult<Gs2.Gs2Key.Result.DeleteKeyResult> asyncResult = null;
yield return client.DeleteKey(
    new Gs2.Gs2Key.Request.DeleteKeyRequest()
        .WithNamespaceName("namespace-0001")
        .WithKeyName("key-0001"),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;

```

**TypeScript**
```typescript

import Gs2Core from '@/gs2/core';
import * as Gs2Key from '@/gs2/key';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Key.Gs2KeyRestClient(session);

try {
    const result = await client.deleteKey(
        new Gs2Key.DeleteKeyRequest()
            .withNamespaceName("namespace-0001")
            .withKeyName("key-0001")
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}

```

**Python**
```python

from gs2 import core
from gs2 import key

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = key.Gs2KeyRestClient(session)

try:
    result = client.delete_key(
        key.DeleteKeyRequest()
            .with_namespace_name('namespace-0001')
            .with_key_name('key-0001')
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)


```

**GS2-Script**
```lua

client = gs2('key')

api_result = client.delete_key({
    namespaceName="namespace-0001",
    keyName="key-0001",
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['errorMessage'])
end

result = api_result.result
item = result.item;

```

**GS2-Script(Async)**
```lua

client = gs2('key')

api_result_handler = client.delete_key_async({
    namespaceName="namespace-0001",
    keyName="key-0001",
})

api_result = api_result_handler()  -- Call the handler to get the result

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['errorMessage'])
end

result = api_result.result
item = result.item;

```




---

### encrypt

Encrypt data

Encrypts the provided plaintext data using the specified encryption key.
The encrypted result is returned as a Base64-encoded string.
The maximum data size is 512KB.



#### Request

|  | Type | Condition | Required | Default | Value Limits | Description |
| --- | --- | --- | --- | --- | --- | --- |
| namespaceName | string |  | ✓|  |  ~ 128 chars | Namespace name<br>Unique Namespace name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). |
| keyName | string |  | ✓|  |  ~ 128 chars | Encryption Key name<br>Unique Encryption Key name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). |
| data | string |  | ✓|  |  ~ 524288 chars |  |

#### Result

|  | Type | Description |
| --- | --- | --- |
| data | string | Encrypted Data |

#### Implementation Example




**Go**
```go

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/key"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := key.Gs2KeyRestClient{
    Session: &session,
}
result, err := client.Encrypt(
    &key.EncryptRequest {
        NamespaceName: pointy.String("namespace-0001"),
        KeyName: pointy.String("key-0001"),
        Data: pointy.String("hoge"),
    }
)
if err != nil {
    panic("error occurred")
}
data := result.Data

```

**PHP**
```php

use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Key\Gs2KeyRestClient;
use Gs2\Key\Request\EncryptRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2KeyRestClient(
    $session
);

try {
    $result = $client->encrypt(
        (new EncryptRequest())
            ->withNamespaceName("namespace-0001")
            ->withKeyName("key-0001")
            ->withData("hoge")
    );
    $data = $result->getData();
} catch (Gs2Exception $e) {
    exit("error occurred")
}

```

**Java**
```java

import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.key.rest.Gs2KeyRestClient;
import io.gs2.key.request.EncryptRequest;
import io.gs2.key.result.EncryptResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    )
);
session.connect();
Gs2KeyRestClient client = new Gs2KeyRestClient(session);

try {
    EncryptResult result = client.encrypt(
        new EncryptRequest()
            .withNamespaceName("namespace-0001")
            .withKeyName("key-0001")
            .withData("hoge")
    );
    String data = result.getData();
} catch (Gs2Exception e) {
    System.exit(1);
}

```

**C#**
```csharp

using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2KeyRestClient(session);

AsyncResult<Gs2.Gs2Key.Result.EncryptResult> asyncResult = null;
yield return client.Encrypt(
    new Gs2.Gs2Key.Request.EncryptRequest()
        .WithNamespaceName("namespace-0001")
        .WithKeyName("key-0001")
        .WithData("hoge"),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var data = result.Data;

```

**TypeScript**
```typescript

import Gs2Core from '@/gs2/core';
import * as Gs2Key from '@/gs2/key';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Key.Gs2KeyRestClient(session);

try {
    const result = await client.encrypt(
        new Gs2Key.EncryptRequest()
            .withNamespaceName("namespace-0001")
            .withKeyName("key-0001")
            .withData("hoge")
    );
    const data = result.getData();
} catch (e) {
    process.exit(1);
}

```

**Python**
```python

from gs2 import core
from gs2 import key

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = key.Gs2KeyRestClient(session)

try:
    result = client.encrypt(
        key.EncryptRequest()
            .with_namespace_name('namespace-0001')
            .with_key_name('key-0001')
            .with_data('hoge')
    )
    data = result.data
except core.Gs2Exception as e:
    exit(1)


```

**GS2-Script**
```lua

client = gs2('key')

api_result = client.encrypt({
    namespaceName="namespace-0001",
    keyName="key-0001",
    data="hoge",
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['errorMessage'])
end

result = api_result.result
data = result.data;

```

**GS2-Script(Async)**
```lua

client = gs2('key')

api_result_handler = client.encrypt_async({
    namespaceName="namespace-0001",
    keyName="key-0001",
    data="hoge",
})

api_result = api_result_handler()  -- Call the handler to get the result

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['errorMessage'])
end

result = api_result.result
data = result.data;

```




---

### decrypt

Decrypt data

Decrypts the provided Base64-encoded encrypted data using the specified encryption key.
The data must have been encrypted with the same key; otherwise decryption will fail.
Returns the original plaintext data.



#### Request

|  | Type | Condition | Required | Default | Value Limits | Description |
| --- | --- | --- | --- | --- | --- | --- |
| namespaceName | string |  | ✓|  |  ~ 128 chars | Namespace name<br>Unique Namespace name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). |
| keyName | string |  | ✓|  |  ~ 128 chars | Encryption Key name<br>Unique Encryption Key name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). |
| data | string |  | ✓|  |  ~ 524288 chars |  |

#### Result

|  | Type | Description |
| --- | --- | --- |
| data | string | Decrypted Data |

#### Implementation Example




**Go**
```go

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/key"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := key.Gs2KeyRestClient{
    Session: &session,
}
result, err := client.Decrypt(
    &key.DecryptRequest {
        NamespaceName: pointy.String("namespace-0001"),
        KeyName: pointy.String("key-0001"),
        Data: pointy.String("hoge"),
    }
)
if err != nil {
    panic("error occurred")
}
data := result.Data

```

**PHP**
```php

use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Key\Gs2KeyRestClient;
use Gs2\Key\Request\DecryptRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2KeyRestClient(
    $session
);

try {
    $result = $client->decrypt(
        (new DecryptRequest())
            ->withNamespaceName("namespace-0001")
            ->withKeyName("key-0001")
            ->withData("hoge")
    );
    $data = $result->getData();
} catch (Gs2Exception $e) {
    exit("error occurred")
}

```

**Java**
```java

import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.key.rest.Gs2KeyRestClient;
import io.gs2.key.request.DecryptRequest;
import io.gs2.key.result.DecryptResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    )
);
session.connect();
Gs2KeyRestClient client = new Gs2KeyRestClient(session);

try {
    DecryptResult result = client.decrypt(
        new DecryptRequest()
            .withNamespaceName("namespace-0001")
            .withKeyName("key-0001")
            .withData("hoge")
    );
    String data = result.getData();
} catch (Gs2Exception e) {
    System.exit(1);
}

```

**C#**
```csharp

using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2KeyRestClient(session);

AsyncResult<Gs2.Gs2Key.Result.DecryptResult> asyncResult = null;
yield return client.Decrypt(
    new Gs2.Gs2Key.Request.DecryptRequest()
        .WithNamespaceName("namespace-0001")
        .WithKeyName("key-0001")
        .WithData("hoge"),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var data = result.Data;

```

**TypeScript**
```typescript

import Gs2Core from '@/gs2/core';
import * as Gs2Key from '@/gs2/key';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Key.Gs2KeyRestClient(session);

try {
    const result = await client.decrypt(
        new Gs2Key.DecryptRequest()
            .withNamespaceName("namespace-0001")
            .withKeyName("key-0001")
            .withData("hoge")
    );
    const data = result.getData();
} catch (e) {
    process.exit(1);
}

```

**Python**
```python

from gs2 import core
from gs2 import key

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = key.Gs2KeyRestClient(session)

try:
    result = client.decrypt(
        key.DecryptRequest()
            .with_namespace_name('namespace-0001')
            .with_key_name('key-0001')
            .with_data('hoge')
    )
    data = result.data
except core.Gs2Exception as e:
    exit(1)


```

**GS2-Script**
```lua

client = gs2('key')

api_result = client.decrypt({
    namespaceName="namespace-0001",
    keyName="key-0001",
    data="hoge",
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['errorMessage'])
end

result = api_result.result
data = result.data;

```

**GS2-Script(Async)**
```lua

client = gs2('key')

api_result_handler = client.decrypt_async({
    namespaceName="namespace-0001",
    keyName="key-0001",
    data="hoge",
})

api_result = api_result_handler()  -- Call the handler to get the result

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['errorMessage'])
end

result = api_result.result
data = result.data;

```




---

### describeGitHubApiKeys

List GitHub API Keys

Retrieves a paginated list of GitHub API keys registered in the specified Namespace.
GitHub API keys are used for fetching master data from GitHub repositories via the UpdateFromGitHub APIs in other GS2 services.
The API key values are stored encrypted and are not included in the listing response.



#### Request

|  | Type | Condition | Required | Default | Value Limits | Description |
| --- | --- | --- | --- | --- | --- | --- |
| namespaceName | string |  | ✓|  |  ~ 128 chars | Namespace name<br>Unique Namespace name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). |
| pageToken | string |  | |  |  ~ 1024 chars | Token specifying the position from which to start acquiring data |
| limit | int |  | | 30 | 1 ~ 1000 | Number of data items to retrieve |

#### Result

|  | Type | Description |
| --- | --- | --- |
| items | [List&lt;GitHubApiKey&gt;](#githubapikey) | List of GitHub API Keys |
| nextPageToken | string | Page token to retrieve the rest of the listing |

#### Implementation Example




**Go**
```go

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/key"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := key.Gs2KeyRestClient{
    Session: &session,
}
result, err := client.DescribeGitHubApiKeys(
    &key.DescribeGitHubApiKeysRequest {
        NamespaceName: pointy.String("namespace-0001"),
        PageToken: nil,
        Limit: nil,
    }
)
if err != nil {
    panic("error occurred")
}
items := result.Items
nextPageToken := result.NextPageToken

```

**PHP**
```php

use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Key\Gs2KeyRestClient;
use Gs2\Key\Request\DescribeGitHubApiKeysRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2KeyRestClient(
    $session
);

try {
    $result = $client->describeGitHubApiKeys(
        (new DescribeGitHubApiKeysRequest())
            ->withNamespaceName("namespace-0001")
            ->withPageToken(null)
            ->withLimit(null)
    );
    $items = $result->getItems();
    $nextPageToken = $result->getNextPageToken();
} catch (Gs2Exception $e) {
    exit("error occurred")
}

```

**Java**
```java

import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.key.rest.Gs2KeyRestClient;
import io.gs2.key.request.DescribeGitHubApiKeysRequest;
import io.gs2.key.result.DescribeGitHubApiKeysResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    )
);
session.connect();
Gs2KeyRestClient client = new Gs2KeyRestClient(session);

try {
    DescribeGitHubApiKeysResult result = client.describeGitHubApiKeys(
        new DescribeGitHubApiKeysRequest()
            .withNamespaceName("namespace-0001")
            .withPageToken(null)
            .withLimit(null)
    );
    List<GitHubApiKey> items = result.getItems();
    String nextPageToken = result.getNextPageToken();
} catch (Gs2Exception e) {
    System.exit(1);
}

```

**C#**
```csharp

using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2KeyRestClient(session);

AsyncResult<Gs2.Gs2Key.Result.DescribeGitHubApiKeysResult> asyncResult = null;
yield return client.DescribeGitHubApiKeys(
    new Gs2.Gs2Key.Request.DescribeGitHubApiKeysRequest()
        .WithNamespaceName("namespace-0001")
        .WithPageToken(null)
        .WithLimit(null),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var items = result.Items;
var nextPageToken = result.NextPageToken;

```

**TypeScript**
```typescript

import Gs2Core from '@/gs2/core';
import * as Gs2Key from '@/gs2/key';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Key.Gs2KeyRestClient(session);

try {
    const result = await client.describeGitHubApiKeys(
        new Gs2Key.DescribeGitHubApiKeysRequest()
            .withNamespaceName("namespace-0001")
            .withPageToken(null)
            .withLimit(null)
    );
    const items = result.getItems();
    const nextPageToken = result.getNextPageToken();
} catch (e) {
    process.exit(1);
}

```

**Python**
```python

from gs2 import core
from gs2 import key

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = key.Gs2KeyRestClient(session)

try:
    result = client.describe_git_hub_api_keys(
        key.DescribeGitHubApiKeysRequest()
            .with_namespace_name('namespace-0001')
            .with_page_token(None)
            .with_limit(None)
    )
    items = result.items
    next_page_token = result.next_page_token
except core.Gs2Exception as e:
    exit(1)


```

**GS2-Script**
```lua

client = gs2('key')

api_result = client.describe_git_hub_api_keys({
    namespaceName="namespace-0001",
    pageToken=nil,
    limit=nil,
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['errorMessage'])
end

result = api_result.result
items = result.items;
nextPageToken = result.nextPageToken;

```

**GS2-Script(Async)**
```lua

client = gs2('key')

api_result_handler = client.describe_git_hub_api_keys_async({
    namespaceName="namespace-0001",
    pageToken=nil,
    limit=nil,
})

api_result = api_result_handler()  -- Call the handler to get the result

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['errorMessage'])
end

result = api_result.result
items = result.items;
nextPageToken = result.nextPageToken;

```




---

### createGitHubApiKey

Create GitHub API Key

Registers a new GitHub API key in the specified Namespace.
The API key value is encrypted using the specified encryption key (encryptionKeyName) before being stored, ensuring secure management.



#### Request

|  | Type | Condition | Required | Default | Value Limits | Description |
| --- | --- | --- | --- | --- | --- | --- |
| namespaceName | string |  | ✓|  |  ~ 128 chars | Namespace name<br>Unique Namespace name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). |
| name | string |  | ✓|  |  ~ 128 chars | GitHub API Key name<br>Unique GitHub API Key name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). |
| description | string |  | |  |  ~ 1024 chars | Description |
| apiKey | string |  | ✓|  |  ~ 1024 chars | API Key<br>The GitHub personal access token or fine-grained token used to authenticate API requests when fetching master data or GS2-Deploy templates from GitHub repositories. Stored encrypted and never exposed in API responses. Maximum 1024 characters. |
| encryptionKeyName | string |  | ✓|  |  ~ 128 chars | Encryption Key name<br>Unique Encryption Key name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). |

#### Result

|  | Type | Description |
| --- | --- | --- |
| item | [GitHubApiKey](#githubapikey) | GitHub API Key created |

#### Implementation Example




**Go**
```go

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/key"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := key.Gs2KeyRestClient{
    Session: &session,
}
result, err := client.CreateGitHubApiKey(
    &key.CreateGitHubApiKeyRequest {
        NamespaceName: pointy.String("namespace-0001"),
        Name: pointy.String("api-key-0001"),
        Description: nil,
        ApiKey: pointy.String("secret-0001"),
        EncryptionKeyName: pointy.String("key-0001"),
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item

```

**PHP**
```php

use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Key\Gs2KeyRestClient;
use Gs2\Key\Request\CreateGitHubApiKeyRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2KeyRestClient(
    $session
);

try {
    $result = $client->createGitHubApiKey(
        (new CreateGitHubApiKeyRequest())
            ->withNamespaceName("namespace-0001")
            ->withName("api-key-0001")
            ->withDescription(null)
            ->withApiKey("secret-0001")
            ->withEncryptionKeyName("key-0001")
    );
    $item = $result->getItem();
} catch (Gs2Exception $e) {
    exit("error occurred")
}

```

**Java**
```java

import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.key.rest.Gs2KeyRestClient;
import io.gs2.key.request.CreateGitHubApiKeyRequest;
import io.gs2.key.result.CreateGitHubApiKeyResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    )
);
session.connect();
Gs2KeyRestClient client = new Gs2KeyRestClient(session);

try {
    CreateGitHubApiKeyResult result = client.createGitHubApiKey(
        new CreateGitHubApiKeyRequest()
            .withNamespaceName("namespace-0001")
            .withName("api-key-0001")
            .withDescription(null)
            .withApiKey("secret-0001")
            .withEncryptionKeyName("key-0001")
    );
    GitHubApiKey item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}

```

**C#**
```csharp

using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2KeyRestClient(session);

AsyncResult<Gs2.Gs2Key.Result.CreateGitHubApiKeyResult> asyncResult = null;
yield return client.CreateGitHubApiKey(
    new Gs2.Gs2Key.Request.CreateGitHubApiKeyRequest()
        .WithNamespaceName("namespace-0001")
        .WithName("api-key-0001")
        .WithDescription(null)
        .WithApiKey("secret-0001")
        .WithEncryptionKeyName("key-0001"),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;

```

**TypeScript**
```typescript

import Gs2Core from '@/gs2/core';
import * as Gs2Key from '@/gs2/key';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Key.Gs2KeyRestClient(session);

try {
    const result = await client.createGitHubApiKey(
        new Gs2Key.CreateGitHubApiKeyRequest()
            .withNamespaceName("namespace-0001")
            .withName("api-key-0001")
            .withDescription(null)
            .withApiKey("secret-0001")
            .withEncryptionKeyName("key-0001")
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}

```

**Python**
```python

from gs2 import core
from gs2 import key

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = key.Gs2KeyRestClient(session)

try:
    result = client.create_git_hub_api_key(
        key.CreateGitHubApiKeyRequest()
            .with_namespace_name('namespace-0001')
            .with_name('api-key-0001')
            .with_description(None)
            .with_api_key('secret-0001')
            .with_encryption_key_name('key-0001')
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)


```

**GS2-Script**
```lua

client = gs2('key')

api_result = client.create_git_hub_api_key({
    namespaceName="namespace-0001",
    name="api-key-0001",
    description=nil,
    apiKey="secret-0001",
    encryptionKeyName="key-0001",
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['errorMessage'])
end

result = api_result.result
item = result.item;

```

**GS2-Script(Async)**
```lua

client = gs2('key')

api_result_handler = client.create_git_hub_api_key_async({
    namespaceName="namespace-0001",
    name="api-key-0001",
    description=nil,
    apiKey="secret-0001",
    encryptionKeyName="key-0001",
})

api_result = api_result_handler()  -- Call the handler to get the result

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['errorMessage'])
end

result = api_result.result
item = result.item;

```




---

### updateGitHubApiKey

Update GitHub API Key

Updates the settings of an existing GitHub API key.
You can change the description, API key value, and the encryption key used for storage.
The new API key value is re-encrypted with the specified encryption key.



#### Request

|  | Type | Condition | Required | Default | Value Limits | Description |
| --- | --- | --- | --- | --- | --- | --- |
| namespaceName | string |  | ✓|  |  ~ 128 chars | Namespace name<br>Unique Namespace name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). |
| apiKeyName | string |  | ✓|  |  ~ 128 chars | GitHub API Key name<br>Unique GitHub API Key name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). |
| description | string |  | |  |  ~ 1024 chars | Description |
| apiKey | string |  | ✓|  |  ~ 1024 chars | API Key<br>The GitHub personal access token or fine-grained token used to authenticate API requests when fetching master data or GS2-Deploy templates from GitHub repositories. Stored encrypted and never exposed in API responses. Maximum 1024 characters. |
| encryptionKeyName | string |  | ✓|  |  ~ 128 chars | Encryption Key name<br>Unique Encryption Key name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). |

#### Result

|  | Type | Description |
| --- | --- | --- |
| item | [GitHubApiKey](#githubapikey) | GitHub API Key updated |

#### Implementation Example




**Go**
```go

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/key"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := key.Gs2KeyRestClient{
    Session: &session,
}
result, err := client.UpdateGitHubApiKey(
    &key.UpdateGitHubApiKeyRequest {
        NamespaceName: pointy.String("namespace-0001"),
        ApiKeyName: pointy.String("api-key-0001"),
        Description: pointy.String("description1"),
        ApiKey: pointy.String("secret-0004"),
        EncryptionKeyName: pointy.String("key-0001"),
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item

```

**PHP**
```php

use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Key\Gs2KeyRestClient;
use Gs2\Key\Request\UpdateGitHubApiKeyRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2KeyRestClient(
    $session
);

try {
    $result = $client->updateGitHubApiKey(
        (new UpdateGitHubApiKeyRequest())
            ->withNamespaceName("namespace-0001")
            ->withApiKeyName("api-key-0001")
            ->withDescription("description1")
            ->withApiKey("secret-0004")
            ->withEncryptionKeyName("key-0001")
    );
    $item = $result->getItem();
} catch (Gs2Exception $e) {
    exit("error occurred")
}

```

**Java**
```java

import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.key.rest.Gs2KeyRestClient;
import io.gs2.key.request.UpdateGitHubApiKeyRequest;
import io.gs2.key.result.UpdateGitHubApiKeyResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    )
);
session.connect();
Gs2KeyRestClient client = new Gs2KeyRestClient(session);

try {
    UpdateGitHubApiKeyResult result = client.updateGitHubApiKey(
        new UpdateGitHubApiKeyRequest()
            .withNamespaceName("namespace-0001")
            .withApiKeyName("api-key-0001")
            .withDescription("description1")
            .withApiKey("secret-0004")
            .withEncryptionKeyName("key-0001")
    );
    GitHubApiKey item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}

```

**C#**
```csharp

using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2KeyRestClient(session);

AsyncResult<Gs2.Gs2Key.Result.UpdateGitHubApiKeyResult> asyncResult = null;
yield return client.UpdateGitHubApiKey(
    new Gs2.Gs2Key.Request.UpdateGitHubApiKeyRequest()
        .WithNamespaceName("namespace-0001")
        .WithApiKeyName("api-key-0001")
        .WithDescription("description1")
        .WithApiKey("secret-0004")
        .WithEncryptionKeyName("key-0001"),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;

```

**TypeScript**
```typescript

import Gs2Core from '@/gs2/core';
import * as Gs2Key from '@/gs2/key';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Key.Gs2KeyRestClient(session);

try {
    const result = await client.updateGitHubApiKey(
        new Gs2Key.UpdateGitHubApiKeyRequest()
            .withNamespaceName("namespace-0001")
            .withApiKeyName("api-key-0001")
            .withDescription("description1")
            .withApiKey("secret-0004")
            .withEncryptionKeyName("key-0001")
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}

```

**Python**
```python

from gs2 import core
from gs2 import key

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = key.Gs2KeyRestClient(session)

try:
    result = client.update_git_hub_api_key(
        key.UpdateGitHubApiKeyRequest()
            .with_namespace_name('namespace-0001')
            .with_api_key_name('api-key-0001')
            .with_description('description1')
            .with_api_key('secret-0004')
            .with_encryption_key_name('key-0001')
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)


```

**GS2-Script**
```lua

client = gs2('key')

api_result = client.update_git_hub_api_key({
    namespaceName="namespace-0001",
    apiKeyName="api-key-0001",
    description="description1",
    apiKey="secret-0004",
    encryptionKeyName="key-0001",
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['errorMessage'])
end

result = api_result.result
item = result.item;

```

**GS2-Script(Async)**
```lua

client = gs2('key')

api_result_handler = client.update_git_hub_api_key_async({
    namespaceName="namespace-0001",
    apiKeyName="api-key-0001",
    description="description1",
    apiKey="secret-0004",
    encryptionKeyName="key-0001",
})

api_result = api_result_handler()  -- Call the handler to get the result

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['errorMessage'])
end

result = api_result.result
item = result.item;

```




---

### getGitHubApiKey

Get GitHub API Key

Retrieves the metadata of a specific GitHub API key.
The actual API key value is not included in the response for security reasons.



#### Request

|  | Type | Condition | Required | Default | Value Limits | Description |
| --- | --- | --- | --- | --- | --- | --- |
| namespaceName | string |  | ✓|  |  ~ 128 chars | Namespace name<br>Unique Namespace name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). |
| apiKeyName | string |  | ✓|  |  ~ 128 chars | GitHub API Key name<br>Unique GitHub API Key name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). |

#### Result

|  | Type | Description |
| --- | --- | --- |
| item | [GitHubApiKey](#githubapikey) | GitHub API Key |

#### Implementation Example




**Go**
```go

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/key"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := key.Gs2KeyRestClient{
    Session: &session,
}
result, err := client.GetGitHubApiKey(
    &key.GetGitHubApiKeyRequest {
        NamespaceName: pointy.String("namespace-0001"),
        ApiKeyName: pointy.String("api-key-0001"),
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item

```

**PHP**
```php

use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Key\Gs2KeyRestClient;
use Gs2\Key\Request\GetGitHubApiKeyRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2KeyRestClient(
    $session
);

try {
    $result = $client->getGitHubApiKey(
        (new GetGitHubApiKeyRequest())
            ->withNamespaceName("namespace-0001")
            ->withApiKeyName("api-key-0001")
    );
    $item = $result->getItem();
} catch (Gs2Exception $e) {
    exit("error occurred")
}

```

**Java**
```java

import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.key.rest.Gs2KeyRestClient;
import io.gs2.key.request.GetGitHubApiKeyRequest;
import io.gs2.key.result.GetGitHubApiKeyResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    )
);
session.connect();
Gs2KeyRestClient client = new Gs2KeyRestClient(session);

try {
    GetGitHubApiKeyResult result = client.getGitHubApiKey(
        new GetGitHubApiKeyRequest()
            .withNamespaceName("namespace-0001")
            .withApiKeyName("api-key-0001")
    );
    GitHubApiKey item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}

```

**C#**
```csharp

using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2KeyRestClient(session);

AsyncResult<Gs2.Gs2Key.Result.GetGitHubApiKeyResult> asyncResult = null;
yield return client.GetGitHubApiKey(
    new Gs2.Gs2Key.Request.GetGitHubApiKeyRequest()
        .WithNamespaceName("namespace-0001")
        .WithApiKeyName("api-key-0001"),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;

```

**TypeScript**
```typescript

import Gs2Core from '@/gs2/core';
import * as Gs2Key from '@/gs2/key';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Key.Gs2KeyRestClient(session);

try {
    const result = await client.getGitHubApiKey(
        new Gs2Key.GetGitHubApiKeyRequest()
            .withNamespaceName("namespace-0001")
            .withApiKeyName("api-key-0001")
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}

```

**Python**
```python

from gs2 import core
from gs2 import key

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = key.Gs2KeyRestClient(session)

try:
    result = client.get_git_hub_api_key(
        key.GetGitHubApiKeyRequest()
            .with_namespace_name('namespace-0001')
            .with_api_key_name('api-key-0001')
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)


```

**GS2-Script**
```lua

client = gs2('key')

api_result = client.get_git_hub_api_key({
    namespaceName="namespace-0001",
    apiKeyName="api-key-0001",
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['errorMessage'])
end

result = api_result.result
item = result.item;

```

**GS2-Script(Async)**
```lua

client = gs2('key')

api_result_handler = client.get_git_hub_api_key_async({
    namespaceName="namespace-0001",
    apiKeyName="api-key-0001",
})

api_result = api_result_handler()  -- Call the handler to get the result

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['errorMessage'])
end

result = api_result.result
item = result.item;

```




---

### deleteGitHubApiKey

Delete GitHub API Key

Deletes the specified GitHub API key and its encrypted value permanently.
After deletion, services that reference this API key for GitHub master data updates will no longer be able to access GitHub repositories.



#### Request

|  | Type | Condition | Required | Default | Value Limits | Description |
| --- | --- | --- | --- | --- | --- | --- |
| namespaceName | string |  | ✓|  |  ~ 128 chars | Namespace name<br>Unique Namespace name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). |
| apiKeyName | string |  | ✓|  |  ~ 128 chars | GitHub API Key name<br>Unique GitHub API Key name. Specified using alphanumeric characters, hyphens (-), underscores (_), and periods (.). |

#### Result

|  | Type | Description |
| --- | --- | --- |
| item | [GitHubApiKey](#githubapikey) | GitHub API Key deleted |

#### Implementation Example




**Go**
```go

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/key"
import "github.com/openlyinc/pointy"

session := core.Gs2RestSession{
    Credential: &core.BasicGs2Credential{
        ClientId: "your client id",
        ClientSecret: "your client secret",
    },
    Region: core.ApNortheast1,
}

if err := session.Connect(); err != nil {
    panic("error occurred")
}

client := key.Gs2KeyRestClient{
    Session: &session,
}
result, err := client.DeleteGitHubApiKey(
    &key.DeleteGitHubApiKeyRequest {
        NamespaceName: pointy.String("namespace-0001"),
        ApiKeyName: pointy.String("api-key-0001"),
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item

```

**PHP**
```php

use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Key\Gs2KeyRestClient;
use Gs2\Key\Request\DeleteGitHubApiKeyRequest;

$session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region::AP_NORTHEAST_1
);

$session->open();

$client = new Gs2KeyRestClient(
    $session
);

try {
    $result = $client->deleteGitHubApiKey(
        (new DeleteGitHubApiKeyRequest())
            ->withNamespaceName("namespace-0001")
            ->withApiKeyName("api-key-0001")
    );
    $item = $result->getItem();
} catch (Gs2Exception $e) {
    exit("error occurred")
}

```

**Java**
```java

import io.gs2.core.model.Region;
import io.gs2.core.model.BasicGs2Credential;
import io.gs2.core.rest.Gs2RestSession;
import io.gs2.core.exception.Gs2Exception;
import io.gs2.key.rest.Gs2KeyRestClient;
import io.gs2.key.request.DeleteGitHubApiKeyRequest;
import io.gs2.key.result.DeleteGitHubApiKeyResult;

Gs2RestSession session = new Gs2RestSession(
    Region.AP_NORTHEAST_1,
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    )
);
session.connect();
Gs2KeyRestClient client = new Gs2KeyRestClient(session);

try {
    DeleteGitHubApiKeyResult result = client.deleteGitHubApiKey(
        new DeleteGitHubApiKeyRequest()
            .withNamespaceName("namespace-0001")
            .withApiKeyName("api-key-0001")
    );
    GitHubApiKey item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}

```

**C#**
```csharp

using Gs2.Core;
using Gs2.Core.Model;
using Gs2.Core.Net;
using Gs2.Core.Exception;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        "your client id",
        "your client secret"
    ),
    Region.ApNortheast1
);
yield return session.OpenAsync(r => { });
var client = new Gs2KeyRestClient(session);

AsyncResult<Gs2.Gs2Key.Result.DeleteGitHubApiKeyResult> asyncResult = null;
yield return client.DeleteGitHubApiKey(
    new Gs2.Gs2Key.Request.DeleteGitHubApiKeyRequest()
        .WithNamespaceName("namespace-0001")
        .WithApiKeyName("api-key-0001"),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;

```

**TypeScript**
```typescript

import Gs2Core from '@/gs2/core';
import * as Gs2Key from '@/gs2/key';

const session = new Gs2Core.Gs2RestSession(
    "ap-northeast-1",
    new Gs2Core.BasicGs2Credential(
        'your client id',
        'your client secret'
    )
);
await session.connect();
const client = new Gs2Key.Gs2KeyRestClient(session);

try {
    const result = await client.deleteGitHubApiKey(
        new Gs2Key.DeleteGitHubApiKeyRequest()
            .withNamespaceName("namespace-0001")
            .withApiKeyName("api-key-0001")
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}

```

**Python**
```python

from gs2 import core
from gs2 import key

session = core.Gs2RestSession(
    core.BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    "ap-northeast-1",
)
session.connect()
client = key.Gs2KeyRestClient(session)

try:
    result = client.delete_git_hub_api_key(
        key.DeleteGitHubApiKeyRequest()
            .with_namespace_name('namespace-0001')
            .with_api_key_name('api-key-0001')
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)


```

**GS2-Script**
```lua

client = gs2('key')

api_result = client.delete_git_hub_api_key({
    namespaceName="namespace-0001",
    apiKeyName="api-key-0001",
})

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['errorMessage'])
end

result = api_result.result
item = result.item;

```

**GS2-Script(Async)**
```lua

client = gs2('key')

api_result_handler = client.delete_git_hub_api_key_async({
    namespaceName="namespace-0001",
    apiKeyName="api-key-0001",
})

api_result = api_result_handler()  -- Call the handler to get the result

if(api_result.isError) then
    -- When error occurs
    fail(api_result['statusCode'], api_result['errorMessage'])
end

result = api_result.result
item = result.item;

```




---



