GS2-Guard SDK API リファレンス

各種プログラミング言語向け GS2-SDK の モデルの仕様 と API のリファレンス

モデル

Namespace

ネームスペース

ネームスペースは一つのプロジェクトで同じサービスを異なる用途で複数利用できるようにするための仕組みです。
GS2 のサービスは基本的にネームスペースというレイヤーがあり、ネームスペースが異なれば同じサービスでもまったく別のデータ空間として取り扱われます。

そのため、各サービスの利用を開始するにあたってネームスペースを作成する必要があります。

有効化条件必須デフォルト値の制限説明
namespaceIdstring
~ 1024文字ネームスペースGRN
namestring
~ 128文字ネームスペース名
descriptionstring~ 1024文字説明文
blockingPolicyBlockingPolicyModel
ブロッキングポリシー
createdAtlong
現在時刻作成日時 (UNIX時間 単位:ミリ秒)
updatedAtlong
現在時刻最終更新日時 (UNIX時間 単位:ミリ秒)
revisionlong0~ 9223372036854775805リビジョン

関連するメソッド

describeNamespaces createNamespace getNamespace updateNamespace deleteNamespace


BlockingPolicyModel

ブロッキングポリシー

有効化条件必須デフォルト値の制限説明
passServicesList<string>
1 ~ 100 itemsアクセス可能なGS2サービスのリスト
defaultRestriction文字列列挙型
enum {
  “Allow”,
  “Deny”
}
“Allow”~ 128文字制限の方針
定義説明
“Allow”条件に一致しないアクセスを許可
“Deny”条件に一致しないアクセスを拒否
locationDetection文字列列挙型
enum {
  “Enable”,
  “Disable”
}
“Disable”~ 128文字アクセス元国検知
定義説明
“Enable”有効
“Disable”無効
locationsList<string>{locationDetection} == “Enable”
1 ~ 100 itemsアクセスを検知する国リスト
locationDetection が “Enable” であれば 必須
locationRestriction文字列列挙型
enum {
  “Allow”,
  “Deny”
}
{locationDetection} == “Enable”
~ 128文字国リストにマッチした際の挙動
定義説明
“Allow”アクセスを許可
“Deny”アクセスを拒否

locationDetection が “Enable” であれば 必須
anonymousIpDetection文字列列挙型
enum {
  “Enable”,
  “Disable”
}
“Disable”~ 128文字匿名IPサービス検知
定義説明
“Enable”有効
“Disable”無効
anonymousIpRestriction文字列列挙型
enum {
  “Deny”
}
{anonymousIpDetection} == “Enable”
“Deny”~ 128文字匿名IPサービス検知時の挙動
定義説明
“Deny”アクセスを拒否

anonymousIpDetection が “Enable” であれば 必須
hostingProviderIpDetection文字列列挙型
enum {
  “Enable”,
  “Disable”
}
“Disable”~ 128文字ホスティングサービス検知
定義説明
“Enable”有効
“Disable”無効
hostingProviderIpRestriction文字列列挙型
enum {
  “Deny”
}
{hostingProviderIpDetection} == “Enable”
“Deny”~ 128文字ホスティングサービス検知時の挙動
定義説明
“Deny”アクセスを拒否

hostingProviderIpDetection が “Enable” であれば 必須
reputationIpDetection文字列列挙型
enum {
  “Enable”,
  “Disable”
}
“Disable”~ 128文字悪意のあるアクセス元IP検知
定義説明
“Enable”有効
“Disable”無効
reputationIpRestriction文字列列挙型
enum {
  “Deny”
}
{reputationIpDetection} == “Enable”
“Deny”~ 128文字悪意のあるアクセス元IP検知時の挙動
定義説明
“Deny”アクセスを拒否

reputationIpDetection が “Enable” であれば 必須
ipAddressesDetection文字列列挙型
enum {
  “Enable”,
  “Disable”
}
“Disable”~ 128文字アクセス元IP検知
定義説明
“Enable”有効
“Disable”無効
ipAddressesList<string>{ipAddressesDetection} == “Enable”~ 100 itemsIPリスト
ipAddressesDetection が “Enable” であれば 有効
ipAddressRestriction文字列列挙型
enum {
  “Allow”,
  “Deny”
}
{ipAddressesDetection} == “Enable”
~ 128文字IPアドレスリストにマッチした際の挙動
定義説明
“Allow”アクセスを許可
“Deny”アクセスを拒否

ipAddressesDetection が “Enable” であれば 必須

関連するメソッド

createNamespace updateNamespace

関連するモデル

namespace


メソッド

describeNamespaces

ネームスペースの一覧を取得

プロジェクト内のすべてのネームスペースの一覧を取得します。
オプションのページトークンを使用して、リストの特定の位置からデータの取得を開始できます。
また、取得するネームスペースの数を制限することも可能です。

Request

有効化条件必須デフォルト値の制限説明
pageTokenstring~ 1024文字データの取得を開始する位置を指定するトークン
limitint
301 ~ 1000データの取得件数

Result

説明
itemsList<Namespace>ネームスペースのリスト
nextPageTokenstringリストの続きを取得するためのページトークン

実装例

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/guard"
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 := guard.Gs2GuardRestClient{
    Session: &session,
}
result, err := client.DescribeNamespaces(
    &guard.DescribeNamespacesRequest {
        PageToken: nil,
        Limit: nil,
    }
)
if err != nil {
    panic("error occurred")
}
items := result.Items
nextPageToken := result.NextPageToken
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Guard\Gs2GuardRestClient;
use Gs2\Guard\Request\DescribeNamespacesRequest;

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

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->describeNamespaces(
        (new DescribeNamespacesRequest())
            ->withPageToken(null)
            ->withLimit(null)
    );
    $items = $result->getItems();
    $nextPageToken = $result->getNextPageToken();
} catch (Gs2Exception $e) {
    exit("error occurred")
}
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.guard.rest.Gs2GuardRestClient;
import io.gs2.guard.request.DescribeNamespacesRequest;
import io.gs2.guard.result.DescribeNamespacesResult;

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

try {
    DescribeNamespacesResult result = client.describeNamespaces(
        new DescribeNamespacesRequest()
            .withPageToken(null)
            .withLimit(null)
    );
    List<Namespace> items = result.getItems();
    String nextPageToken = result.getNextPageToken();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core.Model.Region;
using Gs2.Core.Model.BasicGs2Credential;
using Gs2.Core.Net.Gs2RestSession;
using Gs2.Core.Exception.Gs2Exception;
using Gs2.Core.AsyncResult;
using Gs2.Gs2Guard.Gs2GuardRestClient;
using Gs2.Gs2Guard.Request.DescribeNamespacesRequest;
using Gs2.Gs2Guard.Result.DescribeNamespacesResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2GuardRestClient(session);

AsyncResult<Gs2.Gs2Guard.Result.DescribeNamespacesResult> asyncResult = null;
yield return client.DescribeNamespaces(
    new Gs2.Gs2Guard.Request.DescribeNamespacesRequest()
        .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;
import Gs2Core from '@/gs2/core';
import * as Gs2Guard from '@/gs2/guard';

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

try {
    const result = await client.describeNamespaces(
        new Gs2Guard.DescribeNamespacesRequest()
            .withPageToken(null)
            .withLimit(null)
    );
    const items = result.getItems();
    const nextPageToken = result.getNextPageToken();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import guard

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

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

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

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

result = api_result.result
items = result.items;
nextPageToken = result.nextPageToken;
client = gs2('guard')

api_result_handler = client.describe_namespaces_async({
    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['message'])
end

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

createNamespace

ネームスペースを新規作成

ネームスペースの名前、説明、および各種設定を含む詳細情報を指定する必要があります。

Request

有効化条件必須デフォルト値の制限説明
namestring
~ 128文字ネームスペース名
descriptionstring~ 1024文字説明文
blockingPolicyBlockingPolicyModel
ブロッキングポリシー

Result

説明
itemNamespace作成したネームスペース

実装例

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/guard"
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 := guard.Gs2GuardRestClient{
    Session: &session,
}
result, err := client.CreateNamespace(
    &guard.CreateNamespaceRequest {
        Name: pointy.String("namespace-0001"),
        Description: nil,
        BlockingPolicy: &guard.BlockingPolicyModel{
            PassServices: []*string{
                pointy.String("account"),
            },
            DefaultRestriction: pointy.String("Deny"),
            LocationDetection: pointy.String("Disable"),
            AnonymousIpDetection: pointy.String("Disable"),
            HostingProviderIpDetection: pointy.String("Disable"),
            ReputationIpDetection: pointy.String("Disable"),
            IpAddressesDetection: pointy.String("Enable"),
            IpAddresses: []*string{
                pointy.String("192.168.0.0/24"),
            },
            IpAddressRestriction: pointy.String("Allow"),
        },
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Guard\Gs2GuardRestClient;
use Gs2\Guard\Request\CreateNamespaceRequest;

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

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->createNamespace(
        (new CreateNamespaceRequest())
            ->withName("namespace-0001")
            ->withDescription(null)
            ->withBlockingPolicy((new \Gs2\Guard\Model\BlockingPolicyModel())
                ->withPassServices([
                    "account",
                ])
                ->withDefaultRestriction("Deny")
                ->withLocationDetection("Disable")
                ->withAnonymousIpDetection("Disable")
                ->withHostingProviderIpDetection("Disable")
                ->withReputationIpDetection("Disable")
                ->withIpAddressesDetection("Enable")
                ->withIpAddresses([
                    "192.168.0.0/24",
                ])
                ->withIpAddressRestriction("Allow"))
    );
    $item = $result->getItem();
} catch (Gs2Exception $e) {
    exit("error occurred")
}
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.guard.rest.Gs2GuardRestClient;
import io.gs2.guard.request.CreateNamespaceRequest;
import io.gs2.guard.result.CreateNamespaceResult;

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

try {
    CreateNamespaceResult result = client.createNamespace(
        new CreateNamespaceRequest()
            .withName("namespace-0001")
            .withDescription(null)
            .withBlockingPolicy(new io.gs2.guard.model.BlockingPolicyModel()
                .withPassServices(Arrays.asList(
                    "account"
                ))
                .withDefaultRestriction("Deny")
                .withLocationDetection("Disable")
                .withAnonymousIpDetection("Disable")
                .withHostingProviderIpDetection("Disable")
                .withReputationIpDetection("Disable")
                .withIpAddressesDetection("Enable")
                .withIpAddresses(Arrays.asList(
                    "192.168.0.0/24"
                ))
                .withIpAddressRestriction("Allow"))
    );
    Namespace item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core.Model.Region;
using Gs2.Core.Model.BasicGs2Credential;
using Gs2.Core.Net.Gs2RestSession;
using Gs2.Core.Exception.Gs2Exception;
using Gs2.Core.AsyncResult;
using Gs2.Gs2Guard.Gs2GuardRestClient;
using Gs2.Gs2Guard.Request.CreateNamespaceRequest;
using Gs2.Gs2Guard.Result.CreateNamespaceResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2GuardRestClient(session);

AsyncResult<Gs2.Gs2Guard.Result.CreateNamespaceResult> asyncResult = null;
yield return client.CreateNamespace(
    new Gs2.Gs2Guard.Request.CreateNamespaceRequest()
        .WithName("namespace-0001")
        .WithDescription(null)
        .WithBlockingPolicy(new Gs2.Gs2Guard.Model.BlockingPolicyModel()
            .WithPassServices(new string[] {
                "account",
            })
            .WithDefaultRestriction("Deny")
            .WithLocationDetection("Disable")
            .WithAnonymousIpDetection("Disable")
            .WithHostingProviderIpDetection("Disable")
            .WithReputationIpDetection("Disable")
            .WithIpAddressesDetection("Enable")
            .WithIpAddresses(new string[] {
                "192.168.0.0/24",
            })
            .WithIpAddressRestriction("Allow")),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;
import Gs2Core from '@/gs2/core';
import * as Gs2Guard from '@/gs2/guard';

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

try {
    const result = await client.createNamespace(
        new Gs2Guard.CreateNamespaceRequest()
            .withName("namespace-0001")
            .withDescription(null)
            .withBlockingPolicy(new Gs2Guard.model.BlockingPolicyModel()
                .withPassServices([
                    "account",
                ])
                .withDefaultRestriction("Deny")
                .withLocationDetection("Disable")
                .withAnonymousIpDetection("Disable")
                .withHostingProviderIpDetection("Disable")
                .withReputationIpDetection("Disable")
                .withIpAddressesDetection("Enable")
                .withIpAddresses([
                    "192.168.0.0/24",
                ])
                .withIpAddressRestriction("Allow"))
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import guard

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

try:
    result = client.create_namespace(
        guard.CreateNamespaceRequest()
            .with_name('namespace-0001')
            .with_description(None)
            .with_blocking_policy(
                guard.BlockingPolicyModel()
                    .with_pass_services([
                        'account',
                    ])
                    .with_default_restriction('Deny')
                    .with_location_detection('Disable')
                    .with_anonymous_ip_detection('Disable')
                    .with_hosting_provider_ip_detection('Disable')
                    .with_reputation_ip_detection('Disable')
                    .with_ip_addresses_detection('Enable')
                    .with_ip_addresses([
                        '192.168.0.0/24',
                    ])
                    .with_ip_address_restriction('Allow'))
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('guard')

api_result = client.create_namespace({
    name="namespace-0001",
    description=nil,
    blockingPolicy={
        passServices={
            "account"
        },
        defaultRestriction="Deny",
        locationDetection="Disable",
        anonymousIpDetection="Disable",
        hostingProviderIpDetection="Disable",
        reputationIpDetection="Disable",
        ipAddressesDetection="Enable",
        ipAddresses={
            "192.168.0.0/24"
        },
        ipAddressRestriction="Allow",
    },
})

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

result = api_result.result
item = result.item;
client = gs2('guard')

api_result_handler = client.create_namespace_async({
    name="namespace-0001",
    description=nil,
    blockingPolicy={
        passServices={
            "account"
        },
        defaultRestriction="Deny",
        locationDetection="Disable",
        anonymousIpDetection="Disable",
        hostingProviderIpDetection="Disable",
        reputationIpDetection="Disable",
        ipAddressesDetection="Enable",
        ipAddresses={
            "192.168.0.0/24"
        },
        ipAddressRestriction="Allow",
    },
})

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['message'])
end

result = api_result.result
item = result.item;

getNamespaceStatus

ネームスペースの状態を取得

指定されたネームスペースの現在の状態を取得します。
これには、ネームスペースがアクティブか、保留中か、またはその他の状態にあるかが含まれます。

Request

有効化条件必須デフォルト値の制限説明
namespaceNamestring
~ 128文字ネームスペース名

Result

説明
statusstring

実装例

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/guard"
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 := guard.Gs2GuardRestClient{
    Session: &session,
}
result, err := client.GetNamespaceStatus(
    &guard.GetNamespaceStatusRequest {
        NamespaceName: pointy.String("namespace-0001"),
    }
)
if err != nil {
    panic("error occurred")
}
status := result.Status
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Guard\Gs2GuardRestClient;
use Gs2\Guard\Request\GetNamespaceStatusRequest;

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

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->getNamespaceStatus(
        (new GetNamespaceStatusRequest())
            ->withNamespaceName("namespace-0001")
    );
    $status = $result->getStatus();
} catch (Gs2Exception $e) {
    exit("error occurred")
}
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.guard.rest.Gs2GuardRestClient;
import io.gs2.guard.request.GetNamespaceStatusRequest;
import io.gs2.guard.result.GetNamespaceStatusResult;

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

try {
    GetNamespaceStatusResult result = client.getNamespaceStatus(
        new GetNamespaceStatusRequest()
            .withNamespaceName("namespace-0001")
    );
    String status = result.getStatus();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core.Model.Region;
using Gs2.Core.Model.BasicGs2Credential;
using Gs2.Core.Net.Gs2RestSession;
using Gs2.Core.Exception.Gs2Exception;
using Gs2.Core.AsyncResult;
using Gs2.Gs2Guard.Gs2GuardRestClient;
using Gs2.Gs2Guard.Request.GetNamespaceStatusRequest;
using Gs2.Gs2Guard.Result.GetNamespaceStatusResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2GuardRestClient(session);

AsyncResult<Gs2.Gs2Guard.Result.GetNamespaceStatusResult> asyncResult = null;
yield return client.GetNamespaceStatus(
    new Gs2.Gs2Guard.Request.GetNamespaceStatusRequest()
        .WithNamespaceName("namespace-0001"),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var status = result.Status;
import Gs2Core from '@/gs2/core';
import * as Gs2Guard from '@/gs2/guard';

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

try {
    const result = await client.getNamespaceStatus(
        new Gs2Guard.GetNamespaceStatusRequest()
            .withNamespaceName("namespace-0001")
    );
    const status = result.getStatus();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import guard

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

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

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

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

result = api_result.result
status = result.status;
client = gs2('guard')

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['message'])
end

result = api_result.result
status = result.status;

getNamespace

ネームスペースを取得

指定されたネームスペースの詳細情報を取得します。
これには、ネームスペースの名前、説明、およびその他の設定情報が含まれます。

Request

有効化条件必須デフォルト値の制限説明
namespaceNamestring
~ 128文字ネームスペース名

Result

説明
itemNamespaceネームスペース

実装例

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/guard"
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 := guard.Gs2GuardRestClient{
    Session: &session,
}
result, err := client.GetNamespace(
    &guard.GetNamespaceRequest {
        NamespaceName: pointy.String("namespace-0001"),
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Guard\Gs2GuardRestClient;
use Gs2\Guard\Request\GetNamespaceRequest;

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

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->getNamespace(
        (new GetNamespaceRequest())
            ->withNamespaceName("namespace-0001")
    );
    $item = $result->getItem();
} catch (Gs2Exception $e) {
    exit("error occurred")
}
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.guard.rest.Gs2GuardRestClient;
import io.gs2.guard.request.GetNamespaceRequest;
import io.gs2.guard.result.GetNamespaceResult;

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

try {
    GetNamespaceResult result = client.getNamespace(
        new GetNamespaceRequest()
            .withNamespaceName("namespace-0001")
    );
    Namespace item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core.Model.Region;
using Gs2.Core.Model.BasicGs2Credential;
using Gs2.Core.Net.Gs2RestSession;
using Gs2.Core.Exception.Gs2Exception;
using Gs2.Core.AsyncResult;
using Gs2.Gs2Guard.Gs2GuardRestClient;
using Gs2.Gs2Guard.Request.GetNamespaceRequest;
using Gs2.Gs2Guard.Result.GetNamespaceResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2GuardRestClient(session);

AsyncResult<Gs2.Gs2Guard.Result.GetNamespaceResult> asyncResult = null;
yield return client.GetNamespace(
    new Gs2.Gs2Guard.Request.GetNamespaceRequest()
        .WithNamespaceName("namespace-0001"),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;
import Gs2Core from '@/gs2/core';
import * as Gs2Guard from '@/gs2/guard';

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

try {
    const result = await client.getNamespace(
        new Gs2Guard.GetNamespaceRequest()
            .withNamespaceName("namespace-0001")
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import guard

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

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

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

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

result = api_result.result
item = result.item;
client = gs2('guard')

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['message'])
end

result = api_result.result
item = result.item;

updateNamespace

ネームスペースを更新

指定されたネームスペースの設定を更新します。
ネームスペースの説明や、特定の設定を変更することができます。

Request

有効化条件必須デフォルト値の制限説明
namespaceNamestring
~ 128文字ネームスペース名
descriptionstring~ 1024文字説明文
blockingPolicyBlockingPolicyModel
ブロッキングポリシー

Result

説明
itemNamespace更新したネームスペース

実装例

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/guard"
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 := guard.Gs2GuardRestClient{
    Session: &session,
}
result, err := client.UpdateNamespace(
    &guard.UpdateNamespaceRequest {
        NamespaceName: pointy.String("namespace-0001"),
        Description: pointy.String("description1"),
        BlockingPolicy: &guard.BlockingPolicyModel{
            PassServices: []*string{
                pointy.String("account"),
                pointy.String("dictionary"),
                pointy.String("inventory"),
            },
            DefaultRestriction: pointy.String("Allow"),
            LocationDetection: pointy.String("Enable"),
            Locations: []*string{
                pointy.String("CN"),
            },
            LocationRestriction: pointy.String("Deny"),
        },
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Guard\Gs2GuardRestClient;
use Gs2\Guard\Request\UpdateNamespaceRequest;

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

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->updateNamespace(
        (new UpdateNamespaceRequest())
            ->withNamespaceName("namespace-0001")
            ->withDescription("description1")
            ->withBlockingPolicy((new \Gs2\Guard\Model\BlockingPolicyModel())
                ->withPassServices([
                    "account",
                    "dictionary",
                    "inventory",
                ])
                ->withDefaultRestriction("Allow")
                ->withLocationDetection("Enable")
                ->withLocations([
                    "CN",
                ])
                ->withLocationRestriction("Deny"))
    );
    $item = $result->getItem();
} catch (Gs2Exception $e) {
    exit("error occurred")
}
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.guard.rest.Gs2GuardRestClient;
import io.gs2.guard.request.UpdateNamespaceRequest;
import io.gs2.guard.result.UpdateNamespaceResult;

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

try {
    UpdateNamespaceResult result = client.updateNamespace(
        new UpdateNamespaceRequest()
            .withNamespaceName("namespace-0001")
            .withDescription("description1")
            .withBlockingPolicy(new io.gs2.guard.model.BlockingPolicyModel()
                .withPassServices(Arrays.asList(
                    "account",
                    "dictionary",
                    "inventory"
                ))
                .withDefaultRestriction("Allow")
                .withLocationDetection("Enable")
                .withLocations(Arrays.asList(
                    "CN"
                ))
                .withLocationRestriction("Deny"))
    );
    Namespace item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core.Model.Region;
using Gs2.Core.Model.BasicGs2Credential;
using Gs2.Core.Net.Gs2RestSession;
using Gs2.Core.Exception.Gs2Exception;
using Gs2.Core.AsyncResult;
using Gs2.Gs2Guard.Gs2GuardRestClient;
using Gs2.Gs2Guard.Request.UpdateNamespaceRequest;
using Gs2.Gs2Guard.Result.UpdateNamespaceResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2GuardRestClient(session);

AsyncResult<Gs2.Gs2Guard.Result.UpdateNamespaceResult> asyncResult = null;
yield return client.UpdateNamespace(
    new Gs2.Gs2Guard.Request.UpdateNamespaceRequest()
        .WithNamespaceName("namespace-0001")
        .WithDescription("description1")
        .WithBlockingPolicy(new Gs2.Gs2Guard.Model.BlockingPolicyModel()
            .WithPassServices(new string[] {
                "account",
                "dictionary",
                "inventory",
            })
            .WithDefaultRestriction("Allow")
            .WithLocationDetection("Enable")
            .WithLocations(new string[] {
                "CN",
            })
            .WithLocationRestriction("Deny")),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;
import Gs2Core from '@/gs2/core';
import * as Gs2Guard from '@/gs2/guard';

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

try {
    const result = await client.updateNamespace(
        new Gs2Guard.UpdateNamespaceRequest()
            .withNamespaceName("namespace-0001")
            .withDescription("description1")
            .withBlockingPolicy(new Gs2Guard.model.BlockingPolicyModel()
                .withPassServices([
                    "account",
                    "dictionary",
                    "inventory",
                ])
                .withDefaultRestriction("Allow")
                .withLocationDetection("Enable")
                .withLocations([
                    "CN",
                ])
                .withLocationRestriction("Deny"))
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import guard

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

try:
    result = client.update_namespace(
        guard.UpdateNamespaceRequest()
            .with_namespace_name('namespace-0001')
            .with_description('description1')
            .with_blocking_policy(
                guard.BlockingPolicyModel()
                    .with_pass_services([
                        'account',
                        'dictionary',
                        'inventory',
                    ])
                    .with_default_restriction('Allow')
                    .with_location_detection('Enable')
                    .with_locations([
                        'CN',
                    ])
                    .with_location_restriction('Deny'))
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('guard')

api_result = client.update_namespace({
    namespaceName="namespace-0001",
    description="description1",
    blockingPolicy={
        passServices={
            "account",
            "dictionary",
            "inventory"
        },
        defaultRestriction="Allow",
        locationDetection="Enable",
        locations={
            "CN"
        },
        locationRestriction="Deny",
    },
})

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

result = api_result.result
item = result.item;
client = gs2('guard')

api_result_handler = client.update_namespace_async({
    namespaceName="namespace-0001",
    description="description1",
    blockingPolicy={
        passServices={
            "account",
            "dictionary",
            "inventory"
        },
        defaultRestriction="Allow",
        locationDetection="Enable",
        locations={
            "CN"
        },
        locationRestriction="Deny",
    },
})

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['message'])
end

result = api_result.result
item = result.item;

deleteNamespace

ネームスペースを削除

指定されたネームスペースを削除します。
この操作は不可逆であり、削除されたネームスペースに関連するすべてのデータは回復不能になります。

Request

有効化条件必須デフォルト値の制限説明
namespaceNamestring
~ 128文字ネームスペース名

Result

説明
itemNamespace削除したネームスペース

実装例

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/guard"
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 := guard.Gs2GuardRestClient{
    Session: &session,
}
result, err := client.DeleteNamespace(
    &guard.DeleteNamespaceRequest {
        NamespaceName: pointy.String("namespace-0001"),
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Guard\Gs2GuardRestClient;
use Gs2\Guard\Request\DeleteNamespaceRequest;

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

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->deleteNamespace(
        (new DeleteNamespaceRequest())
            ->withNamespaceName("namespace-0001")
    );
    $item = $result->getItem();
} catch (Gs2Exception $e) {
    exit("error occurred")
}
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.guard.rest.Gs2GuardRestClient;
import io.gs2.guard.request.DeleteNamespaceRequest;
import io.gs2.guard.result.DeleteNamespaceResult;

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

try {
    DeleteNamespaceResult result = client.deleteNamespace(
        new DeleteNamespaceRequest()
            .withNamespaceName("namespace-0001")
    );
    Namespace item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core.Model.Region;
using Gs2.Core.Model.BasicGs2Credential;
using Gs2.Core.Net.Gs2RestSession;
using Gs2.Core.Exception.Gs2Exception;
using Gs2.Core.AsyncResult;
using Gs2.Gs2Guard.Gs2GuardRestClient;
using Gs2.Gs2Guard.Request.DeleteNamespaceRequest;
using Gs2.Gs2Guard.Result.DeleteNamespaceResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2GuardRestClient(session);

AsyncResult<Gs2.Gs2Guard.Result.DeleteNamespaceResult> asyncResult = null;
yield return client.DeleteNamespace(
    new Gs2.Gs2Guard.Request.DeleteNamespaceRequest()
        .WithNamespaceName("namespace-0001"),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;
import Gs2Core from '@/gs2/core';
import * as Gs2Guard from '@/gs2/guard';

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

try {
    const result = await client.deleteNamespace(
        new Gs2Guard.DeleteNamespaceRequest()
            .withNamespaceName("namespace-0001")
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import guard

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

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

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

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

result = api_result.result
item = result.item;
client = gs2('guard')

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['message'])
end

result = api_result.result
item = result.item;

getServiceVersion

マイクロサービスのバージョンを取得

Request

有効化条件必須デフォルト値の制限説明

Result

説明
itemstringバージョン

実装例

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/guard"
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 := guard.Gs2GuardRestClient{
    Session: &session,
}
result, err := client.GetServiceVersion(
    &guard.GetServiceVersionRequest {
    }
)
if err != nil {
    panic("error occurred")
}
item := result.Item
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Guard\Gs2GuardRestClient;
use Gs2\Guard\Request\GetServiceVersionRequest;

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

$session->open();

$client = new Gs2AccountRestClient(
    $session
);

try {
    $result = $client->getServiceVersion(
        (new GetServiceVersionRequest())
    );
    $item = $result->getItem();
} catch (Gs2Exception $e) {
    exit("error occurred")
}
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.guard.rest.Gs2GuardRestClient;
import io.gs2.guard.request.GetServiceVersionRequest;
import io.gs2.guard.result.GetServiceVersionResult;

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

try {
    GetServiceVersionResult result = client.getServiceVersion(
        new GetServiceVersionRequest()
    );
    String item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}
using Gs2.Core.Model.Region;
using Gs2.Core.Model.BasicGs2Credential;
using Gs2.Core.Net.Gs2RestSession;
using Gs2.Core.Exception.Gs2Exception;
using Gs2.Core.AsyncResult;
using Gs2.Gs2Guard.Gs2GuardRestClient;
using Gs2.Gs2Guard.Request.GetServiceVersionRequest;
using Gs2.Gs2Guard.Result.GetServiceVersionResult;

var session = new Gs2RestSession(
    new BasicGs2Credential(
        'your client id',
        'your client secret'
    ),
    Region.ApNortheast1
);
yield return session.Open();
var client = new Gs2GuardRestClient(session);

AsyncResult<Gs2.Gs2Guard.Result.GetServiceVersionResult> asyncResult = null;
yield return client.GetServiceVersion(
    new Gs2.Gs2Guard.Request.GetServiceVersionRequest(),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var item = result.Item;
import Gs2Core from '@/gs2/core';
import * as Gs2Guard from '@/gs2/guard';

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

try {
    const result = await client.getServiceVersion(
        new Gs2Guard.GetServiceVersionRequest()
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import guard

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

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

api_result = client.get_service_version({
})

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

result = api_result.result
item = result.item;
client = gs2('guard')

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['message'])
end

result = api_result.result
item = result.item;