GS2-Deploy SDK API リファレンス

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

モデル

GitHubCheckoutSetting

GitHubからマスターデータをチェックアウトする設定

GitHub リポジトリからテンプレートやマスターデータファイルを直接取得するための設定です。コミットハッシュ・ブランチ名・タグ名による参照をサポートし、認証には GS2-Key の GitHub API キーが必要です。

詳細
有効化条件必須デフォルト値の制限説明
apiKeyIdstring
~ 1024文字GitHub APIキーの GRN
repositoryNamestring
~ 1024文字リポジトリ名
ファイルを取得する GitHub リポジトリ名です。“owner/repo” 形式で指定します。
sourcePathstring
~ 1024文字マスターデータ(JSON)ファイルのパス
リポジトリ内の対象ファイルへのファイルパスです。例えば、“data/master.json” や “deploy/template.yaml” のように指定します。
referenceType文字列列挙型
enum {
  “commit_hash”,
  “branch”,
  “tag”
}
コードの取得元
ファイルのチェックアウトに使用する Git 参照の種類です。commit_hash は再現性のために特定のコミットから取得、branch はブランチの最新を取得、tag はタグ付きリリースから取得します。
定義説明
“commit_hash”コミットハッシュ
“branch”ブランチ
“tag”タグ
commitHashstring{referenceType} == “commit_hash”
✓※
~ 1024文字コミットハッシュ
チェックアウトする Git コミットの完全な SHA です。常に同一バージョンのファイルが取得されることを保証し、デプロイの再現性を提供します。
※ referenceType が “commit_hash” であれば 必須
branchNamestring{referenceType} == “branch”
✓※
~ 1024文字ブランチ名
チェックアウトする Git ブランチ名です。このブランチの最新コミットからファイルが取得されます。
※ referenceType が “branch” であれば 必須
tagNamestring{referenceType} == “tag”
✓※
~ 1024文字タグ名
チェックアウトする Git タグ名です。タグは通常リリースバージョンのマークに使用され、デプロイの安定した参照ポイントを提供します。
※ referenceType が “tag” であれば 必須

Resource

リソース

リソースはスタックによって管理される個々の GS2 サービスエンティティを表します。
各リソースはスタックテンプレートで定義された GS2 API リソース(ネームスペースやモデルなど)に対応します。

詳細
有効化条件必須デフォルト値の制限説明
resourceIdstring
~ 1024文字リソース GRN
※ サーバーが自動で設定
typestring
~ 1024文字リソースの種類
GS2 リソースタイプの識別子です(例: “GS2::Inventory::Namespace”、“GS2::Experience::ExperienceModel”)。このリソースの作成・更新・削除時にどの GS2 API が呼び出されるかを決定します。
namestring
~ 128文字リソース名
スタックテンプレート内でこのリソースに割り当てられた論理名です。テンプレート内での依存関係の解決やアウトプットフィールドのマッピングにおいてリソースを参照するために使用されます。
requeststring
~ 1048576文字リクエストパラメータ
このリソースの作成・更新に使用する JSON シリアライズされた API リクエストパラメータです。
responsestring
~ 1048576文字リソースの作成・更新のレスポンス
リソースの作成・更新時に返された JSON シリアライズされた API レスポンスです。生成された ID やデフォルト値を含む実際のリソース状態が格納されます。
rollbackContext文字列列挙型
enum {
  “create”,
  “update”,
  “delete”
}
ロールバック操作の種類
このリソースのロールバック時に実行する操作の種類です。create はリソースが新規作成されたためロールバック時に削除、update はリソースが変更されたため元に戻す、delete はリソースが削除されたため再作成することを意味します。
定義説明
“create”Create
“update”Update
“delete”Delete
rollbackRequeststring~ 1048576文字ロールバック用のリクエストパラメータ
このリソースのロールバック時に使用する JSON シリアライズされた API リクエストパラメータです。更新されたリソースの場合は復元する以前の状態、削除されたリソースの場合は再作成するための作成パラメータが格納されます。
rollbackAfterList<string>[]0 ~ 1000 itemsロールバック時に依存しているリソースの名前
このリソースより先にロールバックする必要があるリソース名のリストです。整合性を維持するためにロールバック操作が正しい依存順序で実行されることを保証します。
outputFieldsList<OutputField>[]0 ~ 1000 itemsリソースを作成したときに Output に記録するフィールド
API レスポンスからどのフィールドを抽出してスタックのアウトプットとして保存するかを指定します。各エントリはアウトプット名をレスポンス内のフィールドパスにマッピングし、他のスタックや外部システムが作成されたリソースの値を参照できるようにします。
workIdstring
~ 1024文字このリソースが作成された時の実行 ID
このリソースをプロビジョニングしたスタック操作(作成/更新)の一意な識別子です。
createdAtlong
現在時刻作成日時
UNIX 時間・ミリ秒
※ サーバーが自動で設定

Event

イベント

スタック内のリソースの作成、更新、削除などの操作が行われる際、情報を提供するためにイベントが生成されます。
スタックのデプロイプロセスやリソースの変更がどのように進行しているかを開発者がモニタリングし、必要な対応を行うことができます。

詳細
有効化条件必須デフォルト値の制限説明
eventIdstring
~ 1024文字イベント GRN
※ サーバーが自動で設定
namestring
UUID~ 36文字イベント名
イベントの一意な名前を保持します。
名前はUUID(Universally Unique Identifier)フォーマットで自動的に生成され、各イベントを識別するために使用されます。
resourceNamestring
~ 128文字リソース名
スタックテンプレート内でこのリソースに割り当てられた論理名です。テンプレート内での依存関係の解決やアウトプットフィールドのマッピングにおいてリソースを参照するために使用されます。
type文字列列挙型
enum {
  “CREATE_IN_PROGRESS”,
  “CREATE_COMPLETE”,
  “CREATE_FAILED”,
  “UPDATE_IN_PROGRESS”,
  “UPDATE_COMPLETE”,
  “UPDATE_FAILED”,
  “CLEAN_IN_PROGRESS”,
  “CLEAN_COMPLETE”,
  “CLEAN_FAILED”,
  “DELETE_IN_PROGRESS”,
  “DELETE_COMPLETE”,
  “DELETE_FAILED”,
  “ROLLBACK_IN_PROGRESS”,
  “ROLLBACK_COMPLETE”,
  “ROLLBACK_FAILED”
}
状態
リソース操作の現在の状態を示すイベントの種類です。個々のリソースに対する作成・更新・クリーン・削除・ロールバック操作の処理中・完了・失敗の状態を追跡します。
定義説明
“CREATE_IN_PROGRESS”作成中
“CREATE_COMPLETE”作成完了
“CREATE_FAILED”作成失敗
“UPDATE_IN_PROGRESS”更新中
“UPDATE_COMPLETE”更新完了
“UPDATE_FAILED”更新失敗
“CLEAN_IN_PROGRESS”リソース削除中
“CLEAN_COMPLETE”リソース削除完了
“CLEAN_FAILED”リソース削除失敗
“DELETE_IN_PROGRESS”削除中
“DELETE_COMPLETE”削除完了
“DELETE_FAILED”削除失敗
“ROLLBACK_IN_PROGRESS”ロールバック中
“ROLLBACK_COMPLETE”ロールバック完了
“ROLLBACK_FAILED”ロールバック失敗
messagestring~ 5242880文字メッセージ
イベントの詳細を説明するメッセージです。失敗した操作の場合、リソース操作が失敗した理由を説明するエラーメッセージが含まれます。成功した操作の場合、完了したアクションに関する追加のコンテキストが含まれることがあります。
eventAtlong
現在時刻作成日時
UNIX 時間・ミリ秒
※ サーバーが自動で設定
revisionlong00 ~ 9223372036854775805リビジョン

Output

スタックによって作成される出力

スタックの Outputs セクションに記録したいデータを記載することで、このモデルを使用して出力を作成できます。
たとえば、クレデンシャルを作成する際にクライアントシークレットは作成した瞬間にしか確認できませんが、その内容を出力として記録することで後でクライアントシークレットの値を参照することができるようになります。

詳細
有効化条件必須デフォルト値の制限説明
outputIdstring
~ 1024文字アウトプット GRN
※ サーバーが自動で設定
namestring
~ 1024文字アウトプット名
スタックテンプレートの Outputs セクションで定義されたアウトプットの論理名です。他のスタックや外部システムからこのアウトプット値を参照するために使用されます。
valuestring~ 1048576文字
リソースの API レスポンスから抽出された実際のアウトプット値です。例えば、リソース作成時に生成されたクライアントシークレットやリソース ARN など、後から参照可能な値が格納されます。
createdAtlong
現在時刻作成日時
UNIX 時間・ミリ秒
※ サーバーが自動で設定

Stack

スタック

スタックとは GS2-Deploy を利用してGS2上のリソースをセットアップするエンティティです。

スタックにはテンプレートファイルを指定するようになっており、テンプレートファイルには GS2 上で必要となるリソースを定義します。
GS2-Deploy はスタックを新規作成または更新する際にはテンプレートファイルの変更点を検出し、追加があればリソースを作成、変更があればリソースを更新、削除があればリソースを削除します。

この仕組みを利用することで、GS2上のリソースを宣言的に記述し、再現可能な状態で管理することが可能となります。
この再現性があることで、開発環境から本番環境に設定を移行する際などにミスなく実行できるようになります。

詳細
有効化条件必須デフォルト値の制限説明
stackIdstring
~ 1024文字スタック GRN
※ サーバーが自動で設定
namestring
~ 128文字スタック名
スタックを識別する一意な名前です。英数字および -(ハイフン) _(アンダースコア) .(ピリオド)で指定します。作成・更新・削除操作時にスタックを参照するために使用されます。
descriptionstring~ 1024文字説明文
templatestring
~ 5242880文字テンプレートデータ
プロビジョニングする GS2 リソースを宣言的に定義する YAML または JSON ドキュメントです。GS2-Deploy は現在と以前のテンプレートの差分を検出し、必要に応じてリソースの作成・更新・削除を行います。最大サイズは 5 MB です。
status文字列列挙型
enum {
  “CREATE_PROCESSING”,
  “CREATE_COMPLETE”,
  “UPDATE_PROCESSING”,
  “UPDATE_COMPLETE”,
  “CLEAN_PROCESSING”,
  “CLEAN_COMPLETE”,
  “DELETE_PROCESSING”,
  “DELETE_COMPLETE”,
  “ROLLBACK_INITIALIZING”,
  “ROLLBACK_PROCESSING”,
  “ROLLBACK_COMPLETE”
}
“CREATE_PROCESSING”実行状態
スタック操作の現在のライフサイクル状態です。作成・更新・クリーン(リソース削除)・削除・ロールバック操作の処理中および完了状態を遷移します。操作の失敗時にはロールバックがトリガーされ、以前の状態に復元される場合があります。
定義説明
“CREATE_PROCESSING”作成中
“CREATE_COMPLETE”作成完了
“UPDATE_PROCESSING”更新中
“UPDATE_COMPLETE”更新完了
“CLEAN_PROCESSING”リソース削除中
“CLEAN_COMPLETE”リソース削除完了
“DELETE_PROCESSING”削除中
“DELETE_COMPLETE”削除完了
“ROLLBACK_INITIALIZING”ロールバック初期化中
“ROLLBACK_PROCESSING”ロールバック中
“ROLLBACK_COMPLETE”ロールバック完了
createdAtlong
現在時刻作成日時
UNIX 時間・ミリ秒
※ サーバーが自動で設定
updatedAtlong
現在時刻最終更新日時
UNIX 時間・ミリ秒
※ サーバーが自動で設定
revisionlong00 ~ 9223372036854775805リビジョン

OutputField

アウトプットフィールド

リソースの API レスポンスフィールドから名前付きスタックアウトプットへのマッピングを定義します。

詳細
有効化条件必須デフォルト値の制限説明
namestring
~ 1024文字名前
抽出された値が格納されるアウトプットのキー名です。スタックの Outputs からアウトプット値を参照する際にこの名前が使用されます。
fieldNamestring
~ 1024文字フィールド名
値を抽出するリソースの API レスポンス内のフィールドパスです。作成・更新されたリソースのどのプロパティをアウトプットとして記録するかを指定します。

ChangeSet

変更内容

現在のスタックテンプレートと新しいテンプレートを比較した際に検出された単一のリソース変更を表します。スタック更新の実行前に、どのリソースが作成・更新・削除されるかをプレビューするバリデーション操作で使用されます。

詳細
有効化条件必須デフォルト値の制限説明
resourceNamestring
~ 128文字リソース名
この変更の影響を受ける、スタックテンプレートで定義されたリソースの論理名です。
resourceTypestring
~ 128文字リソースの種類
変更されるリソースの GS2 リソースタイプ識別子です(例: “GS2::Inventory::Namespace”)。
operation文字列列挙型
enum {
  “create”,
  “update”,
  “delete”
}
変更内容
このリソースに適用される変更の種類です。create は新しいリソースがプロビジョニングされること、update は既存のリソースが変更されること、delete はリソースが削除されることを示します。
定義説明
“create”作成
“update”更新
“delete”削除

メソッド

describeResources

リソースの一覧を取得

指定されたスタックによって管理されているリソースのページネーション付きリストを取得します。
各リソースは、スタックのテンプレートによってプロビジョニングされた GS2 サービスコンポーネント(ネームスペース、モデル、構成など)を表します。
リソース情報には、タイプ、名前、現在のリクエストボディ、関連するプロパティが含まれます。

詳細

Request

有効化条件必須デフォルト値の制限説明
stackNamestring
~ 128文字スタック名
スタックを識別する一意な名前です。英数字および -(ハイフン) _(アンダースコア) .(ピリオド)で指定します。作成・更新・削除操作時にスタックを参照するために使用されます。
pageTokenstring~ 1024文字データの取得を開始する位置を指定するトークン
limitint301 ~ 1000データの取得件数

Result

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

実装例

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/deploy"
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 := deploy.Gs2DeployRestClient{
    Session: &session,
}
result, err := client.DescribeResources(
    &deploy.DescribeResourcesRequest {
        StackName: pointy.String("stack-0001"),
        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\Deploy\Gs2DeployRestClient;
use Gs2\Deploy\Request\DescribeResourcesRequest;

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

$session->open();

$client = new Gs2DeployRestClient(
    $session
);

try {
    $result = $client->describeResources(
        (new DescribeResourcesRequest())
            ->withStackName("stack-0001")
            ->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.deploy.rest.Gs2DeployRestClient;
import io.gs2.deploy.request.DescribeResourcesRequest;
import io.gs2.deploy.result.DescribeResourcesResult;

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

try {
    DescribeResourcesResult result = client.describeResources(
        new DescribeResourcesRequest()
            .withStackName("stack-0001")
            .withPageToken(null)
            .withLimit(null)
    );
    List<Resource> items = result.getItems();
    String nextPageToken = result.getNextPageToken();
} catch (Gs2Exception e) {
    System.exit(1);
}
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 Gs2DeployRestClient(session);

AsyncResult<Gs2.Gs2Deploy.Result.DescribeResourcesResult> asyncResult = null;
yield return client.DescribeResources(
    new Gs2.Gs2Deploy.Request.DescribeResourcesRequest()
        .WithStackName("stack-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;
import Gs2Core from '@/gs2/core';
import * as Gs2Deploy from '@/gs2/deploy';

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

try {
    const result = await client.describeResources(
        new Gs2Deploy.DescribeResourcesRequest()
            .withStackName("stack-0001")
            .withPageToken(null)
            .withLimit(null)
    );
    const items = result.getItems();
    const nextPageToken = result.getNextPageToken();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import deploy

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

try:
    result = client.describe_resources(
        deploy.DescribeResourcesRequest()
            .with_stack_name('stack-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)
client = gs2('deploy')

api_result = client.describe_resources({
    stackName="stack-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;
client = gs2('deploy')

api_result_handler = client.describe_resources_async({
    stackName="stack-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;

getResource

リソースを取得

スタックによって管理されている特定のリソースの詳細情報を取得します。
リソースの詳細には、タイプ、名前、プロビジョニングに使用されたリクエストボディ、作成後に返されたレスポンスプロパティが含まれます。

詳細

Request

有効化条件必須デフォルト値の制限説明
stackNamestring
~ 128文字スタック名
スタックを識別する一意な名前です。英数字および -(ハイフン) _(アンダースコア) .(ピリオド)で指定します。作成・更新・削除操作時にスタックを参照するために使用されます。
resourceNamestring
~ 128文字リソース名
スタックテンプレート内でこのリソースに割り当てられた論理名です。テンプレート内での依存関係の解決やアウトプットフィールドのマッピングにおいてリソースを参照するために使用されます。

Result

説明
itemResourceリソース

実装例

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/deploy"
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 := deploy.Gs2DeployRestClient{
    Session: &session,
}
result, err := client.GetResource(
    &deploy.GetResourceRequest {
        StackName: pointy.String("stack-0001"),
        ResourceName: pointy.String("resource-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\Deploy\Gs2DeployRestClient;
use Gs2\Deploy\Request\GetResourceRequest;

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

$session->open();

$client = new Gs2DeployRestClient(
    $session
);

try {
    $result = $client->getResource(
        (new GetResourceRequest())
            ->withStackName("stack-0001")
            ->withResourceName("resource-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.deploy.rest.Gs2DeployRestClient;
import io.gs2.deploy.request.GetResourceRequest;
import io.gs2.deploy.result.GetResourceResult;

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

try {
    GetResourceResult result = client.getResource(
        new GetResourceRequest()
            .withStackName("stack-0001")
            .withResourceName("resource-0001")
    );
    Resource item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}
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 Gs2DeployRestClient(session);

AsyncResult<Gs2.Gs2Deploy.Result.GetResourceResult> asyncResult = null;
yield return client.GetResource(
    new Gs2.Gs2Deploy.Request.GetResourceRequest()
        .WithStackName("stack-0001")
        .WithResourceName("resource-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 Gs2Deploy from '@/gs2/deploy';

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

try {
    const result = await client.getResource(
        new Gs2Deploy.GetResourceRequest()
            .withStackName("stack-0001")
            .withResourceName("resource-0001")
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import deploy

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

try:
    result = client.get_resource(
        deploy.GetResourceRequest()
            .with_stack_name('stack-0001')
            .with_resource_name('resource-0001')
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('deploy')

api_result = client.get_resource({
    stackName="stack-0001",
    resourceName="resource-0001",
})

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

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

api_result_handler = client.get_resource_async({
    stackName="stack-0001",
    resourceName="resource-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;

describeEvents

イベントの一覧を取得

スタック操作(作成、更新、削除)中に発生したイベントのページネーション付きリストを取得します。
イベントには、各リソース操作の進行状況と結果(リソースタイプ、実行されたアクション、エラーメッセージなど)が記録されます。
実行中の操作のステータス監視や、完了した操作の履歴確認に便利です。

詳細

Request

有効化条件必須デフォルト値の制限説明
stackNamestring
~ 128文字スタック名
スタックを識別する一意な名前です。英数字および -(ハイフン) _(アンダースコア) .(ピリオド)で指定します。作成・更新・削除操作時にスタックを参照するために使用されます。
pageTokenstring~ 1024文字データの取得を開始する位置を指定するトークン
limitint301 ~ 1000データの取得件数

Result

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

実装例

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/deploy"
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 := deploy.Gs2DeployRestClient{
    Session: &session,
}
result, err := client.DescribeEvents(
    &deploy.DescribeEventsRequest {
        StackName: pointy.String("stack-0001"),
        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\Deploy\Gs2DeployRestClient;
use Gs2\Deploy\Request\DescribeEventsRequest;

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

$session->open();

$client = new Gs2DeployRestClient(
    $session
);

try {
    $result = $client->describeEvents(
        (new DescribeEventsRequest())
            ->withStackName("stack-0001")
            ->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.deploy.rest.Gs2DeployRestClient;
import io.gs2.deploy.request.DescribeEventsRequest;
import io.gs2.deploy.result.DescribeEventsResult;

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

try {
    DescribeEventsResult result = client.describeEvents(
        new DescribeEventsRequest()
            .withStackName("stack-0001")
            .withPageToken(null)
            .withLimit(null)
    );
    List<Event> items = result.getItems();
    String nextPageToken = result.getNextPageToken();
} catch (Gs2Exception e) {
    System.exit(1);
}
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 Gs2DeployRestClient(session);

AsyncResult<Gs2.Gs2Deploy.Result.DescribeEventsResult> asyncResult = null;
yield return client.DescribeEvents(
    new Gs2.Gs2Deploy.Request.DescribeEventsRequest()
        .WithStackName("stack-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;
import Gs2Core from '@/gs2/core';
import * as Gs2Deploy from '@/gs2/deploy';

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

try {
    const result = await client.describeEvents(
        new Gs2Deploy.DescribeEventsRequest()
            .withStackName("stack-0001")
            .withPageToken(null)
            .withLimit(null)
    );
    const items = result.getItems();
    const nextPageToken = result.getNextPageToken();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import deploy

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

try:
    result = client.describe_events(
        deploy.DescribeEventsRequest()
            .with_stack_name('stack-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)
client = gs2('deploy')

api_result = client.describe_events({
    stackName="stack-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;
client = gs2('deploy')

api_result_handler = client.describe_events_async({
    stackName="stack-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;

getEvent

イベントを取得

スタック内の特定のイベントの詳細情報を取得します。
イベントには、リソースタイプ、アクション(作成/更新/削除)、ステータス、操作中に発生したエラーメッセージが含まれます。

詳細

Request

有効化条件必須デフォルト値の制限説明
stackNamestring
~ 128文字スタック名
スタックを識別する一意な名前です。英数字および -(ハイフン) _(アンダースコア) .(ピリオド)で指定します。作成・更新・削除操作時にスタックを参照するために使用されます。
eventNamestring
UUID~ 36文字イベント名
イベントの一意な名前を保持します。
名前はUUID(Universally Unique Identifier)フォーマットで自動的に生成され、各イベントを識別するために使用されます。

Result

説明
itemEventイベント

実装例

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/deploy"
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 := deploy.Gs2DeployRestClient{
    Session: &session,
}
result, err := client.GetEvent(
    &deploy.GetEventRequest {
        StackName: pointy.String("stack-0001"),
        EventName: pointy.String("event-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\Deploy\Gs2DeployRestClient;
use Gs2\Deploy\Request\GetEventRequest;

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

$session->open();

$client = new Gs2DeployRestClient(
    $session
);

try {
    $result = $client->getEvent(
        (new GetEventRequest())
            ->withStackName("stack-0001")
            ->withEventName("event-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.deploy.rest.Gs2DeployRestClient;
import io.gs2.deploy.request.GetEventRequest;
import io.gs2.deploy.result.GetEventResult;

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

try {
    GetEventResult result = client.getEvent(
        new GetEventRequest()
            .withStackName("stack-0001")
            .withEventName("event-0001")
    );
    Event item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}
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 Gs2DeployRestClient(session);

AsyncResult<Gs2.Gs2Deploy.Result.GetEventResult> asyncResult = null;
yield return client.GetEvent(
    new Gs2.Gs2Deploy.Request.GetEventRequest()
        .WithStackName("stack-0001")
        .WithEventName("event-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 Gs2Deploy from '@/gs2/deploy';

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

try {
    const result = await client.getEvent(
        new Gs2Deploy.GetEventRequest()
            .withStackName("stack-0001")
            .withEventName("event-0001")
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import deploy

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

try:
    result = client.get_event(
        deploy.GetEventRequest()
            .with_stack_name('stack-0001')
            .with_event_name('event-0001')
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('deploy')

api_result = client.get_event({
    stackName="stack-0001",
    eventName="event-0001",
})

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

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

api_result_handler = client.get_event_async({
    stackName="stack-0001",
    eventName="event-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;

describeOutputs

アウトプットの一覧を取得

スタックの作成・更新が成功した後に生成されたアウトプット値のページネーション付きリストを取得します。
アウトプットは、テンプレートで定義されたキーと値のペアで、スタックのプロビジョニング中に生成されたリソース識別子、エンドポイント、構成値などの重要な情報を公開します。
アウトプットはスタックが _COMPLETE ステータスの場合にのみ利用可能です。

詳細

Request

有効化条件必須デフォルト値の制限説明
stackNamestring
~ 128文字スタック名
スタックを識別する一意な名前です。英数字および -(ハイフン) _(アンダースコア) .(ピリオド)で指定します。作成・更新・削除操作時にスタックを参照するために使用されます。
pageTokenstring~ 1024文字データの取得を開始する位置を指定するトークン
limitint301 ~ 1000データの取得件数

Result

説明
itemsList<Output>アウトプットのリスト
nextPageTokenstringリストの続きを取得するためのページトークン

実装例

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/deploy"
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 := deploy.Gs2DeployRestClient{
    Session: &session,
}
result, err := client.DescribeOutputs(
    &deploy.DescribeOutputsRequest {
        StackName: pointy.String("stack-0001"),
        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\Deploy\Gs2DeployRestClient;
use Gs2\Deploy\Request\DescribeOutputsRequest;

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

$session->open();

$client = new Gs2DeployRestClient(
    $session
);

try {
    $result = $client->describeOutputs(
        (new DescribeOutputsRequest())
            ->withStackName("stack-0001")
            ->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.deploy.rest.Gs2DeployRestClient;
import io.gs2.deploy.request.DescribeOutputsRequest;
import io.gs2.deploy.result.DescribeOutputsResult;

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

try {
    DescribeOutputsResult result = client.describeOutputs(
        new DescribeOutputsRequest()
            .withStackName("stack-0001")
            .withPageToken(null)
            .withLimit(null)
    );
    List<Output> items = result.getItems();
    String nextPageToken = result.getNextPageToken();
} catch (Gs2Exception e) {
    System.exit(1);
}
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 Gs2DeployRestClient(session);

AsyncResult<Gs2.Gs2Deploy.Result.DescribeOutputsResult> asyncResult = null;
yield return client.DescribeOutputs(
    new Gs2.Gs2Deploy.Request.DescribeOutputsRequest()
        .WithStackName("stack-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;
import Gs2Core from '@/gs2/core';
import * as Gs2Deploy from '@/gs2/deploy';

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

try {
    const result = await client.describeOutputs(
        new Gs2Deploy.DescribeOutputsRequest()
            .withStackName("stack-0001")
            .withPageToken(null)
            .withLimit(null)
    );
    const items = result.getItems();
    const nextPageToken = result.getNextPageToken();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import deploy

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

try:
    result = client.describe_outputs(
        deploy.DescribeOutputsRequest()
            .with_stack_name('stack-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)
client = gs2('deploy')

api_result = client.describe_outputs({
    stackName="stack-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;
client = gs2('deploy')

api_result_handler = client.describe_outputs_async({
    stackName="stack-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;

getOutput

アウトプットを取得

スタックから名前を指定して特定のアウトプット値を取得します。
アウトプットには、キー名とスタックのプロビジョニング中に生成された対応する値が含まれます。

詳細

Request

有効化条件必須デフォルト値の制限説明
stackNamestring
~ 128文字スタック名
スタックを識別する一意な名前です。英数字および -(ハイフン) _(アンダースコア) .(ピリオド)で指定します。作成・更新・削除操作時にスタックを参照するために使用されます。
outputNamestring
~ 1024文字アウトプット名
スタックテンプレートの Outputs セクションで定義されたアウトプットの論理名です。他のスタックや外部システムからこのアウトプット値を参照するために使用されます。

Result

説明
itemOutputアウトプット

実装例

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/deploy"
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 := deploy.Gs2DeployRestClient{
    Session: &session,
}
result, err := client.GetOutput(
    &deploy.GetOutputRequest {
        StackName: pointy.String("stack-0001"),
        OutputName: pointy.String("output-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\Deploy\Gs2DeployRestClient;
use Gs2\Deploy\Request\GetOutputRequest;

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

$session->open();

$client = new Gs2DeployRestClient(
    $session
);

try {
    $result = $client->getOutput(
        (new GetOutputRequest())
            ->withStackName("stack-0001")
            ->withOutputName("output-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.deploy.rest.Gs2DeployRestClient;
import io.gs2.deploy.request.GetOutputRequest;
import io.gs2.deploy.result.GetOutputResult;

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

try {
    GetOutputResult result = client.getOutput(
        new GetOutputRequest()
            .withStackName("stack-0001")
            .withOutputName("output-0001")
    );
    Output item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}
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 Gs2DeployRestClient(session);

AsyncResult<Gs2.Gs2Deploy.Result.GetOutputResult> asyncResult = null;
yield return client.GetOutput(
    new Gs2.Gs2Deploy.Request.GetOutputRequest()
        .WithStackName("stack-0001")
        .WithOutputName("output-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 Gs2Deploy from '@/gs2/deploy';

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

try {
    const result = await client.getOutput(
        new Gs2Deploy.GetOutputRequest()
            .withStackName("stack-0001")
            .withOutputName("output-0001")
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import deploy

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

try:
    result = client.get_output(
        deploy.GetOutputRequest()
            .with_stack_name('stack-0001')
            .with_output_name('output-0001')
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('deploy')

api_result = client.get_output({
    stackName="stack-0001",
    outputName="output-0001",
})

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

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

api_result_handler = client.get_output_async({
    stackName="stack-0001",
    outputName="output-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;

describeStacks

スタックの一覧を取得

名前の接頭辞によるフィルタリングを指定して、スタックのリストを取得します。
ページトークンと取得件数の制限を使用して、結果をインクリメンタルに取得できます。
リスト内の各スタックには、現在のステータス、名前、説明、テンプレート情報が含まれます。

詳細

Request

有効化条件必須デフォルト値の制限説明
namePrefixstring~ 64文字スタック名のフィルター接頭辞
pageTokenstring~ 1024文字データの取得を開始する位置を指定するトークン
limitint301 ~ 1000データの取得件数

Result

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

実装例

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/deploy"
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 := deploy.Gs2DeployRestClient{
    Session: &session,
}
result, err := client.DescribeStacks(
    &deploy.DescribeStacksRequest {
        NamePrefix: nil,
        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\Deploy\Gs2DeployRestClient;
use Gs2\Deploy\Request\DescribeStacksRequest;

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

$session->open();

$client = new Gs2DeployRestClient(
    $session
);

try {
    $result = $client->describeStacks(
        (new DescribeStacksRequest())
            ->withNamePrefix(null)
            ->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.deploy.rest.Gs2DeployRestClient;
import io.gs2.deploy.request.DescribeStacksRequest;
import io.gs2.deploy.result.DescribeStacksResult;

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

try {
    DescribeStacksResult result = client.describeStacks(
        new DescribeStacksRequest()
            .withNamePrefix(null)
            .withPageToken(null)
            .withLimit(null)
    );
    List<Stack> items = result.getItems();
    String nextPageToken = result.getNextPageToken();
} catch (Gs2Exception e) {
    System.exit(1);
}
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 Gs2DeployRestClient(session);

AsyncResult<Gs2.Gs2Deploy.Result.DescribeStacksResult> asyncResult = null;
yield return client.DescribeStacks(
    new Gs2.Gs2Deploy.Request.DescribeStacksRequest()
        .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;
import Gs2Core from '@/gs2/core';
import * as Gs2Deploy from '@/gs2/deploy';

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

try {
    const result = await client.describeStacks(
        new Gs2Deploy.DescribeStacksRequest()
            .withNamePrefix(null)
            .withPageToken(null)
            .withLimit(null)
    );
    const items = result.getItems();
    const nextPageToken = result.getNextPageToken();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import deploy

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

try:
    result = client.describe_stacks(
        deploy.DescribeStacksRequest()
            .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)
client = gs2('deploy')

api_result = client.describe_stacks({
    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;
client = gs2('deploy')

api_result_handler = client.describe_stacks_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;

preCreateStack

スタックの新規作成を準備(事前アップロード)

テンプレートファイルをアップロードするためのアップロードトークンと署名付き URL を取得します。
テンプレートが 1MB を超える場合、この3フェーズのフローが必要です:1) この API を呼び出してアップロード URL を取得、2) テンプレートを URL にアップロード、3) preUpload モードでアップロードトークンを指定して CreateStack を呼び出し。
署名付き URL の有効期限は60分です。

詳細

Request

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

Result

説明
uploadTokenstringアップロード後に結果を反映する際に使用するトークン
uploadUrlstringアップロード処理の実行に使用するURL

実装例

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/deploy"
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 := deploy.Gs2DeployRestClient{
    Session: &session,
}
result, err := client.PreCreateStack(
    &deploy.PreCreateStackRequest {
    }
)
if err != nil {
    panic("error occurred")
}
uploadToken := result.UploadToken
uploadUrl := result.UploadUrl
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Deploy\Gs2DeployRestClient;
use Gs2\Deploy\Request\PreCreateStackRequest;

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

$session->open();

$client = new Gs2DeployRestClient(
    $session
);

try {
    $result = $client->preCreateStack(
        (new PreCreateStackRequest())
    );
    $uploadToken = $result->getUploadToken();
    $uploadUrl = $result->getUploadUrl();
} 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.deploy.rest.Gs2DeployRestClient;
import io.gs2.deploy.request.PreCreateStackRequest;
import io.gs2.deploy.result.PreCreateStackResult;

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

try {
    PreCreateStackResult result = client.preCreateStack(
        new PreCreateStackRequest()
    );
    String uploadToken = result.getUploadToken();
    String uploadUrl = result.getUploadUrl();
} catch (Gs2Exception e) {
    System.exit(1);
}
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 Gs2DeployRestClient(session);

AsyncResult<Gs2.Gs2Deploy.Result.PreCreateStackResult> asyncResult = null;
yield return client.PreCreateStack(
    new Gs2.Gs2Deploy.Request.PreCreateStackRequest(),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var uploadToken = result.UploadToken;
var uploadUrl = result.UploadUrl;
import Gs2Core from '@/gs2/core';
import * as Gs2Deploy from '@/gs2/deploy';

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

try {
    const result = await client.preCreateStack(
        new Gs2Deploy.PreCreateStackRequest()
    );
    const uploadToken = result.getUploadToken();
    const uploadUrl = result.getUploadUrl();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import deploy

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

try:
    result = client.pre_create_stack(
        deploy.PreCreateStackRequest()
    )
    upload_token = result.upload_token
    upload_url = result.upload_url
except core.Gs2Exception as e:
    exit(1)
client = gs2('deploy')

api_result = client.pre_create_stack({
})

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

result = api_result.result
uploadToken = result.uploadToken;
uploadUrl = result.uploadUrl;
client = gs2('deploy')

api_result_handler = client.pre_create_stack_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
uploadToken = result.uploadToken;
uploadUrl = result.uploadUrl;

createStack

スタックを新規作成

名前、説明、テンプレートを指定して新しいスタックを作成します。
2つのモードをサポートしています:テンプレートをリクエストボディにインラインで渡す ‘direct’ モードと、PreCreateStack API で事前にアップロードしたテンプレートを使用する ‘preUpload’ モードです。
テンプレートはスタック作成前に検証されます。検証に失敗した場合、エラーが返されます。
作成後、スタックは CREATE_PROCESSING ステータスに入り、リソースのプロビジョニングが非同期で開始されます。

詳細

Request

有効化条件必須デフォルト値の制限説明
namestring
~ 128文字スタック名
スタックを識別する一意な名前です。英数字および -(ハイフン) _(アンダースコア) .(ピリオド)で指定します。作成・更新・削除操作時にスタックを参照するために使用されます。
descriptionstring~ 1024文字説明文
mode文字列列挙型
enum {
  “direct”,
  “preUpload”
}
“direct”更新モード
定義説明
“direct”マスターデータを直接更新
“preUpload”マスターデータをアップロードしてから更新
templatestring{mode} == “direct”
✓※
~ 5242880文字テンプレートデータ
プロビジョニングする GS2 リソースを宣言的に定義する YAML または JSON ドキュメントです。GS2-Deploy は現在と以前のテンプレートの差分を検出し、必要に応じてリソースの作成・更新・削除を行います。最大サイズは 5 MB です。
※ mode が “direct” であれば必須
uploadTokenstring{mode} == “preUpload”
✓※
~ 1024文字事前アップロードで取得したトークン
アップロードしたマスターデータを適用するために使用されます。
※ mode が “preUpload” であれば必須

Result

説明
itemStack作成したスタック

実装例

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/deploy"
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 := deploy.Gs2DeployRestClient{
    Session: &session,
}
result, err := client.CreateStack(
    &deploy.CreateStackRequest {
        Name: pointy.String("stack-0001"),
        Description: nil,
        Mode: nil,
        Template: pointy.String("\nGS2TemplateFormatVersion: \"2019-05-01\"\nDescription: Template Sample\n\nResources:\n  IdentifierAuthUser:\n    Type: GS2::Identifier::User\n    Properties:\n      Name: auth\n\nOutputs:\n  SecretKey: !GetAttr IdentifierAuthUser.Name\n"),
        UploadToken: nil,
    }
)
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\Deploy\Gs2DeployRestClient;
use Gs2\Deploy\Request\CreateStackRequest;

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

$session->open();

$client = new Gs2DeployRestClient(
    $session
);

try {
    $result = $client->createStack(
        (new CreateStackRequest())
            ->withName("stack-0001")
            ->withDescription(null)
            ->withMode(null)
            ->withTemplate("\nGS2TemplateFormatVersion: \"2019-05-01\"\nDescription: Template Sample\n\nResources:\n  IdentifierAuthUser:\n    Type: GS2::Identifier::User\n    Properties:\n      Name: auth\n\nOutputs:\n  SecretKey: !GetAttr IdentifierAuthUser.Name\n")
            ->withUploadToken(null)
    );
    $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.deploy.rest.Gs2DeployRestClient;
import io.gs2.deploy.request.CreateStackRequest;
import io.gs2.deploy.result.CreateStackResult;

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

try {
    CreateStackResult result = client.createStack(
        new CreateStackRequest()
            .withName("stack-0001")
            .withDescription(null)
            .withMode(null)
            .withTemplate("\nGS2TemplateFormatVersion: \"2019-05-01\"\nDescription: Template Sample\n\nResources:\n  IdentifierAuthUser:\n    Type: GS2::Identifier::User\n    Properties:\n      Name: auth\n\nOutputs:\n  SecretKey: !GetAttr IdentifierAuthUser.Name\n")
            .withUploadToken(null)
    );
    Stack item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}
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 Gs2DeployRestClient(session);

AsyncResult<Gs2.Gs2Deploy.Result.CreateStackResult> asyncResult = null;
yield return client.CreateStack(
    new Gs2.Gs2Deploy.Request.CreateStackRequest()
        .WithName("stack-0001")
        .WithDescription(null)
        .WithMode(null)
        .WithTemplate("\nGS2TemplateFormatVersion: \"2019-05-01\"\nDescription: Template Sample\n\nResources:\n  IdentifierAuthUser:\n    Type: GS2::Identifier::User\n    Properties:\n      Name: auth\n\nOutputs:\n  SecretKey: !GetAttr IdentifierAuthUser.Name\n")
        .WithUploadToken(null),
    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 Gs2Deploy from '@/gs2/deploy';

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

try {
    const result = await client.createStack(
        new Gs2Deploy.CreateStackRequest()
            .withName("stack-0001")
            .withDescription(null)
            .withMode(null)
            .withTemplate("\nGS2TemplateFormatVersion: \"2019-05-01\"\nDescription: Template Sample\n\nResources:\n  IdentifierAuthUser:\n    Type: GS2::Identifier::User\n    Properties:\n      Name: auth\n\nOutputs:\n  SecretKey: !GetAttr IdentifierAuthUser.Name\n")
            .withUploadToken(null)
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import deploy

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

try:
    result = client.create_stack(
        deploy.CreateStackRequest()
            .with_name('stack-0001')
            .with_description(None)
            .with_mode(None)
            .with_template('\nGS2TemplateFormatVersion: "2019-05-01"\nDescription: Template Sample\n\nResources:\n  IdentifierAuthUser:\n    Type: GS2::Identifier::User\n    Properties:\n      Name: auth\n\nOutputs:\n  SecretKey: !GetAttr IdentifierAuthUser.Name\n')
            .with_upload_token(None)
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('deploy')

api_result = client.create_stack({
    name="stack-0001",
    description=nil,
    mode=nil,
    template="\nGS2TemplateFormatVersion: \"2019-05-01\"\nDescription: Template Sample\n\nResources:\n  IdentifierAuthUser:\n    Type: GS2::Identifier::User\n    Properties:\n      Name: auth\n\nOutputs:\n  SecretKey: !GetAttr IdentifierAuthUser.Name\n",
    uploadToken=nil,
})

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

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

api_result_handler = client.create_stack_async({
    name="stack-0001",
    description=nil,
    mode=nil,
    template="\nGS2TemplateFormatVersion: \"2019-05-01\"\nDescription: Template Sample\n\nResources:\n  IdentifierAuthUser:\n    Type: GS2::Identifier::User\n    Properties:\n      Name: auth\n\nOutputs:\n  SecretKey: !GetAttr IdentifierAuthUser.Name\n",
    uploadToken=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;

createStackFromGitHub

GitHub からスタックを新規作成

GitHub リポジトリから直接テンプレートを取得して新しいスタックを作成します。
チェックアウト設定には、テンプレートのリポジトリ、ブランチまたはタグ、ファイルパスを指定します。
取得したテンプレートはスタック作成前に検証されます。
テンプレートをバージョン管理で管理し、リポジトリから直接インフラストラクチャをデプロイする場合に便利です。

詳細

Request

有効化条件必須デフォルト値の制限説明
namestring
~ 128文字スタック名
スタックを識別する一意な名前です。英数字および -(ハイフン) _(アンダースコア) .(ピリオド)で指定します。作成・更新・削除操作時にスタックを参照するために使用されます。
descriptionstring~ 1024文字説明文
checkoutSettingGitHubCheckoutSetting
GitHubからテンプレートファイルをチェックアウトしてくる設定

Result

説明
itemStack作成したスタック

実装例

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/deploy"
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 := deploy.Gs2DeployRestClient{
    Session: &session,
}
result, err := client.CreateStackFromGitHub(
    &deploy.CreateStackFromGitHubRequest {
        Name: pointy.String("stack-0001"),
        Description: nil,
        CheckoutSetting: &deploy.GitHubCheckoutSetting{
            ApiKeyId: pointy.String("apiKeyId-0001"),
            RepositoryName: pointy.String("gs2io/master-data"),
            SourcePath: pointy.String("path/to/file.json"),
            ReferenceType: pointy.String("branch"),
            BranchName: pointy.String("develop"),
        },
    }
)
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\Deploy\Gs2DeployRestClient;
use Gs2\Deploy\Request\CreateStackFromGitHubRequest;

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

$session->open();

$client = new Gs2DeployRestClient(
    $session
);

try {
    $result = $client->createStackFromGitHub(
        (new CreateStackFromGitHubRequest())
            ->withName("stack-0001")
            ->withDescription(null)
            ->withCheckoutSetting((new GitHubCheckoutSetting())
                ->withApiKeyId("apiKeyId-0001")
                ->withRepositoryName("gs2io/master-data")
                ->withSourcePath("path/to/file.json")
                ->withReferenceType("branch")
                ->withBranchName("develop")
            )
    );
    $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.deploy.rest.Gs2DeployRestClient;
import io.gs2.deploy.request.CreateStackFromGitHubRequest;
import io.gs2.deploy.result.CreateStackFromGitHubResult;

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

try {
    CreateStackFromGitHubResult result = client.createStackFromGitHub(
        new CreateStackFromGitHubRequest()
            .withName("stack-0001")
            .withDescription(null)
            .withCheckoutSetting(new GitHubCheckoutSetting()
                .withApiKeyId("apiKeyId-0001")
                .withRepositoryName("gs2io/master-data")
                .withSourcePath("path/to/file.json")
                .withReferenceType("branch")
                .withBranchName("develop")
            )
    );
    Stack item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}
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 Gs2DeployRestClient(session);

AsyncResult<Gs2.Gs2Deploy.Result.CreateStackFromGitHubResult> asyncResult = null;
yield return client.CreateStackFromGitHub(
    new Gs2.Gs2Deploy.Request.CreateStackFromGitHubRequest()
        .WithName("stack-0001")
        .WithDescription(null)
        .WithCheckoutSetting(new Gs2.Gs2Deploy.Model.GitHubCheckoutSetting()
            .WithApiKeyId("apiKeyId-0001")
            .WithRepositoryName("gs2io/master-data")
            .WithSourcePath("path/to/file.json")
            .WithReferenceType("branch")
            .WithBranchName("develop")
        ),
    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 Gs2Deploy from '@/gs2/deploy';

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

try {
    const result = await client.createStackFromGitHub(
        new Gs2Deploy.CreateStackFromGitHubRequest()
            .withName("stack-0001")
            .withDescription(null)
            .withCheckoutSetting(new Gs2Deploy.model.GitHubCheckoutSetting()
                .withApiKeyId("apiKeyId-0001")
                .withRepositoryName("gs2io/master-data")
                .withSourcePath("path/to/file.json")
                .withReferenceType("branch")
                .withBranchName("develop")
            )
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import deploy

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

try:
    result = client.create_stack_from_git_hub(
        deploy.CreateStackFromGitHubRequest()
            .with_name('stack-0001')
            .with_description(None)
            .with_checkout_setting(deploy.GitHubCheckoutSetting()
                .with_api_key_id('apiKeyId-0001')
                .with_repository_name('gs2io/master-data')
                .with_source_path('path/to/file.json')
                .with_reference_type('branch')
                .with_branch_name('develop')
            )
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('deploy')

api_result = client.create_stack_from_git_hub({
    name="stack-0001",
    description=nil,
    checkoutSetting={
        api_key_id="apiKeyId-0001",
        repository_name="gs2io/master-data",
        source_path="path/to/file.json",
        reference_type="branch",
        branch_name="develop",
    },
})

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

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

api_result_handler = client.create_stack_from_git_hub_async({
    name="stack-0001",
    description=nil,
    checkoutSetting={
        api_key_id="apiKeyId-0001",
        repository_name="gs2io/master-data",
        source_path="path/to/file.json",
        reference_type="branch",
        branch_name="develop",
    },
})

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;

preValidate

テンプレートの検証を準備(事前アップロード)

検証するテンプレートファイルをアップロードするためのアップロードトークンと署名付き URL を取得します。
テンプレートが 1MB を超える場合、この3フェーズのフローが必要です:1) この API を呼び出してアップロード URL を取得、2) テンプレートを URL にアップロード、3) preUpload モードでアップロードトークンを指定して Validate を呼び出し。
署名付き URL の有効期限は60分です。

詳細

Request

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

Result

説明
uploadTokenstringアップロード後に結果を反映する際に使用するトークン
uploadUrlstringアップロード処理の実行に使用するURL

実装例

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/deploy"
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 := deploy.Gs2DeployRestClient{
    Session: &session,
}
result, err := client.PreValidate(
    &deploy.PreValidateRequest {
    }
)
if err != nil {
    panic("error occurred")
}
uploadToken := result.UploadToken
uploadUrl := result.UploadUrl
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Deploy\Gs2DeployRestClient;
use Gs2\Deploy\Request\PreValidateRequest;

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

$session->open();

$client = new Gs2DeployRestClient(
    $session
);

try {
    $result = $client->preValidate(
        (new PreValidateRequest())
    );
    $uploadToken = $result->getUploadToken();
    $uploadUrl = $result->getUploadUrl();
} 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.deploy.rest.Gs2DeployRestClient;
import io.gs2.deploy.request.PreValidateRequest;
import io.gs2.deploy.result.PreValidateResult;

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

try {
    PreValidateResult result = client.preValidate(
        new PreValidateRequest()
    );
    String uploadToken = result.getUploadToken();
    String uploadUrl = result.getUploadUrl();
} catch (Gs2Exception e) {
    System.exit(1);
}
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 Gs2DeployRestClient(session);

AsyncResult<Gs2.Gs2Deploy.Result.PreValidateResult> asyncResult = null;
yield return client.PreValidate(
    new Gs2.Gs2Deploy.Request.PreValidateRequest(),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var uploadToken = result.UploadToken;
var uploadUrl = result.UploadUrl;
import Gs2Core from '@/gs2/core';
import * as Gs2Deploy from '@/gs2/deploy';

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

try {
    const result = await client.preValidate(
        new Gs2Deploy.PreValidateRequest()
    );
    const uploadToken = result.getUploadToken();
    const uploadUrl = result.getUploadUrl();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import deploy

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

try:
    result = client.pre_validate(
        deploy.PreValidateRequest()
    )
    upload_token = result.upload_token
    upload_url = result.upload_url
except core.Gs2Exception as e:
    exit(1)
client = gs2('deploy')

api_result = client.pre_validate({
})

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

result = api_result.result
uploadToken = result.uploadToken;
uploadUrl = result.uploadUrl;
client = gs2('deploy')

api_result_handler = client.pre_validate_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
uploadToken = result.uploadToken;
uploadUrl = result.uploadUrl;

validate

テンプレートを検証

実際にスタックを作成・更新せずに、テンプレートの構造と構文を検証します。
2つのモードをサポートしています:テンプレートをインラインで渡す ‘direct’ モードと、PreValidate API で事前にアップロードしたテンプレートを使用する ‘preUpload’ モードです。
この API は構造的な検証のみを行います。検証をパスしても、実際のスタック作成・更新時にランタイムエラーが発生する可能性があります。

詳細

Request

有効化条件必須デフォルト値の制限説明
mode文字列列挙型
enum {
  “direct”,
  “preUpload”
}
“direct”更新モード
定義説明
“direct”マスターデータを直接更新
“preUpload”マスターデータをアップロードしてから更新
templatestring{mode} == “direct”
✓※
~ 5242880文字テンプレートデータ
プロビジョニングする GS2 リソースを宣言的に定義する YAML または JSON ドキュメントです。GS2-Deploy は現在と以前のテンプレートの差分を検出し、必要に応じてリソースの作成・更新・削除を行います。最大サイズは 5 MB です。
※ mode が “direct” であれば必須
uploadTokenstring{mode} == “preUpload”
✓※
~ 1024文字事前アップロードで取得したトークン
アップロードしたマスターデータを適用するために使用されます。
※ mode が “preUpload” であれば必須

Result

説明

実装例

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/deploy"
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 := deploy.Gs2DeployRestClient{
    Session: &session,
}
result, err := client.Validate(
    &deploy.ValidateRequest {
        Mode: nil,
        Template: pointy.String("\nGS2TemplateFormatVersion: \"2019-05-01\"\nDescription: Template Sample\n\nResources:\n  IdentifierAuthUser:\n    Type: GS2::Identifier::User\n    Properties:\n      Name: auth\n\nOutputs:\n  SecretKey: !GetAttr IdentifierAuthUser.Name\n"),
        UploadToken: nil,
    }
)
if err != nil {
    panic("error occurred")
}
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Deploy\Gs2DeployRestClient;
use Gs2\Deploy\Request\ValidateRequest;

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

$session->open();

$client = new Gs2DeployRestClient(
    $session
);

try {
    $result = $client->validate(
        (new ValidateRequest())
            ->withMode(null)
            ->withTemplate("\nGS2TemplateFormatVersion: \"2019-05-01\"\nDescription: Template Sample\n\nResources:\n  IdentifierAuthUser:\n    Type: GS2::Identifier::User\n    Properties:\n      Name: auth\n\nOutputs:\n  SecretKey: !GetAttr IdentifierAuthUser.Name\n")
            ->withUploadToken(null)
    );
} 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.deploy.rest.Gs2DeployRestClient;
import io.gs2.deploy.request.ValidateRequest;
import io.gs2.deploy.result.ValidateResult;

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

try {
    ValidateResult result = client.validate(
        new ValidateRequest()
            .withMode(null)
            .withTemplate("\nGS2TemplateFormatVersion: \"2019-05-01\"\nDescription: Template Sample\n\nResources:\n  IdentifierAuthUser:\n    Type: GS2::Identifier::User\n    Properties:\n      Name: auth\n\nOutputs:\n  SecretKey: !GetAttr IdentifierAuthUser.Name\n")
            .withUploadToken(null)
    );
} catch (Gs2Exception e) {
    System.exit(1);
}
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 Gs2DeployRestClient(session);

AsyncResult<Gs2.Gs2Deploy.Result.ValidateResult> asyncResult = null;
yield return client.Validate(
    new Gs2.Gs2Deploy.Request.ValidateRequest()
        .WithMode(null)
        .WithTemplate("\nGS2TemplateFormatVersion: \"2019-05-01\"\nDescription: Template Sample\n\nResources:\n  IdentifierAuthUser:\n    Type: GS2::Identifier::User\n    Properties:\n      Name: auth\n\nOutputs:\n  SecretKey: !GetAttr IdentifierAuthUser.Name\n")
        .WithUploadToken(null),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
import Gs2Core from '@/gs2/core';
import * as Gs2Deploy from '@/gs2/deploy';

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

try {
    const result = await client.validate(
        new Gs2Deploy.ValidateRequest()
            .withMode(null)
            .withTemplate("\nGS2TemplateFormatVersion: \"2019-05-01\"\nDescription: Template Sample\n\nResources:\n  IdentifierAuthUser:\n    Type: GS2::Identifier::User\n    Properties:\n      Name: auth\n\nOutputs:\n  SecretKey: !GetAttr IdentifierAuthUser.Name\n")
            .withUploadToken(null)
    );
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import deploy

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

try:
    result = client.validate(
        deploy.ValidateRequest()
            .with_mode(None)
            .with_template('\nGS2TemplateFormatVersion: "2019-05-01"\nDescription: Template Sample\n\nResources:\n  IdentifierAuthUser:\n    Type: GS2::Identifier::User\n    Properties:\n      Name: auth\n\nOutputs:\n  SecretKey: !GetAttr IdentifierAuthUser.Name\n')
            .with_upload_token(None)
    )
except core.Gs2Exception as e:
    exit(1)
client = gs2('deploy')

api_result = client.validate({
    mode=nil,
    template="\nGS2TemplateFormatVersion: \"2019-05-01\"\nDescription: Template Sample\n\nResources:\n  IdentifierAuthUser:\n    Type: GS2::Identifier::User\n    Properties:\n      Name: auth\n\nOutputs:\n  SecretKey: !GetAttr IdentifierAuthUser.Name\n",
    uploadToken=nil,
})

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

result = api_result.result
client = gs2('deploy')

api_result_handler = client.validate_async({
    mode=nil,
    template="\nGS2TemplateFormatVersion: \"2019-05-01\"\nDescription: Template Sample\n\nResources:\n  IdentifierAuthUser:\n    Type: GS2::Identifier::User\n    Properties:\n      Name: auth\n\nOutputs:\n  SecretKey: !GetAttr IdentifierAuthUser.Name\n",
    uploadToken=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

getStackStatus

スタックのステータスを取得

指定されたスタックの現在のステータスのみを取得します。
ステータス文字列のみを返す API であり、スタック操作の進行状況をポーリングする場合に適しています。

詳細

Request

有効化条件必須デフォルト値の制限説明
stackNamestring
~ 128文字スタック名
スタックを識別する一意な名前です。英数字および -(ハイフン) _(アンダースコア) .(ピリオド)で指定します。作成・更新・削除操作時にスタックを参照するために使用されます。

Result

説明
statusstring

実装例

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/deploy"
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 := deploy.Gs2DeployRestClient{
    Session: &session,
}
result, err := client.GetStackStatus(
    &deploy.GetStackStatusRequest {
        StackName: pointy.String("stack-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\Deploy\Gs2DeployRestClient;
use Gs2\Deploy\Request\GetStackStatusRequest;

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

$session->open();

$client = new Gs2DeployRestClient(
    $session
);

try {
    $result = $client->getStackStatus(
        (new GetStackStatusRequest())
            ->withStackName("stack-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.deploy.rest.Gs2DeployRestClient;
import io.gs2.deploy.request.GetStackStatusRequest;
import io.gs2.deploy.result.GetStackStatusResult;

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

try {
    GetStackStatusResult result = client.getStackStatus(
        new GetStackStatusRequest()
            .withStackName("stack-0001")
    );
    String status = result.getStatus();
} catch (Gs2Exception e) {
    System.exit(1);
}
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 Gs2DeployRestClient(session);

AsyncResult<Gs2.Gs2Deploy.Result.GetStackStatusResult> asyncResult = null;
yield return client.GetStackStatus(
    new Gs2.Gs2Deploy.Request.GetStackStatusRequest()
        .WithStackName("stack-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 Gs2Deploy from '@/gs2/deploy';

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

try {
    const result = await client.getStackStatus(
        new Gs2Deploy.GetStackStatusRequest()
            .withStackName("stack-0001")
    );
    const status = result.getStatus();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import deploy

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

try:
    result = client.get_stack_status(
        deploy.GetStackStatusRequest()
            .with_stack_name('stack-0001')
    )
    status = result.status
except core.Gs2Exception as e:
    exit(1)
client = gs2('deploy')

api_result = client.get_stack_status({
    stackName="stack-0001",
})

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

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

api_result_handler = client.get_stack_status_async({
    stackName="stack-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;

getStack

スタックを取得

指定されたスタックの詳細情報(名前、説明、テンプレート、ステータス、関連リソースなど)を取得します。

詳細

Request

有効化条件必須デフォルト値の制限説明
stackNamestring
~ 128文字スタック名
スタックを識別する一意な名前です。英数字および -(ハイフン) _(アンダースコア) .(ピリオド)で指定します。作成・更新・削除操作時にスタックを参照するために使用されます。

Result

説明
itemStackスタック

実装例

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/deploy"
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 := deploy.Gs2DeployRestClient{
    Session: &session,
}
result, err := client.GetStack(
    &deploy.GetStackRequest {
        StackName: pointy.String("stack-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\Deploy\Gs2DeployRestClient;
use Gs2\Deploy\Request\GetStackRequest;

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

$session->open();

$client = new Gs2DeployRestClient(
    $session
);

try {
    $result = $client->getStack(
        (new GetStackRequest())
            ->withStackName("stack-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.deploy.rest.Gs2DeployRestClient;
import io.gs2.deploy.request.GetStackRequest;
import io.gs2.deploy.result.GetStackResult;

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

try {
    GetStackResult result = client.getStack(
        new GetStackRequest()
            .withStackName("stack-0001")
    );
    Stack item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}
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 Gs2DeployRestClient(session);

AsyncResult<Gs2.Gs2Deploy.Result.GetStackResult> asyncResult = null;
yield return client.GetStack(
    new Gs2.Gs2Deploy.Request.GetStackRequest()
        .WithStackName("stack-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 Gs2Deploy from '@/gs2/deploy';

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

try {
    const result = await client.getStack(
        new Gs2Deploy.GetStackRequest()
            .withStackName("stack-0001")
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import deploy

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

try:
    result = client.get_stack(
        deploy.GetStackRequest()
            .with_stack_name('stack-0001')
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('deploy')

api_result = client.get_stack({
    stackName="stack-0001",
})

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

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

api_result_handler = client.get_stack_async({
    stackName="stack-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;

preUpdateStack

スタックの更新を準備(事前アップロード)

スタックを更新するための新しいテンプレートファイルをアップロードするためのアップロードトークンと署名付き URL を取得します。
テンプレートが 1MB を超える場合、この3フェーズのフローが必要です:1) この API を呼び出してアップロード URL を取得、2) テンプレートを URL にアップロード、3) preUpload モードでアップロードトークンを指定して UpdateStack を呼び出し。
署名付き URL の有効期限は60分です。

詳細

Request

有効化条件必須デフォルト値の制限説明
stackNamestring
~ 128文字スタック名
スタックを識別する一意な名前です。英数字および -(ハイフン) _(アンダースコア) .(ピリオド)で指定します。作成・更新・削除操作時にスタックを参照するために使用されます。

Result

説明
uploadTokenstringアップロード後に結果を反映する際に使用するトークン
uploadUrlstringアップロード処理の実行に使用するURL

実装例

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/deploy"
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 := deploy.Gs2DeployRestClient{
    Session: &session,
}
result, err := client.PreUpdateStack(
    &deploy.PreUpdateStackRequest {
        StackName: pointy.String("stack-0001"),
    }
)
if err != nil {
    panic("error occurred")
}
uploadToken := result.UploadToken
uploadUrl := result.UploadUrl
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Deploy\Gs2DeployRestClient;
use Gs2\Deploy\Request\PreUpdateStackRequest;

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

$session->open();

$client = new Gs2DeployRestClient(
    $session
);

try {
    $result = $client->preUpdateStack(
        (new PreUpdateStackRequest())
            ->withStackName("stack-0001")
    );
    $uploadToken = $result->getUploadToken();
    $uploadUrl = $result->getUploadUrl();
} 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.deploy.rest.Gs2DeployRestClient;
import io.gs2.deploy.request.PreUpdateStackRequest;
import io.gs2.deploy.result.PreUpdateStackResult;

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

try {
    PreUpdateStackResult result = client.preUpdateStack(
        new PreUpdateStackRequest()
            .withStackName("stack-0001")
    );
    String uploadToken = result.getUploadToken();
    String uploadUrl = result.getUploadUrl();
} catch (Gs2Exception e) {
    System.exit(1);
}
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 Gs2DeployRestClient(session);

AsyncResult<Gs2.Gs2Deploy.Result.PreUpdateStackResult> asyncResult = null;
yield return client.PreUpdateStack(
    new Gs2.Gs2Deploy.Request.PreUpdateStackRequest()
        .WithStackName("stack-0001"),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var uploadToken = result.UploadToken;
var uploadUrl = result.UploadUrl;
import Gs2Core from '@/gs2/core';
import * as Gs2Deploy from '@/gs2/deploy';

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

try {
    const result = await client.preUpdateStack(
        new Gs2Deploy.PreUpdateStackRequest()
            .withStackName("stack-0001")
    );
    const uploadToken = result.getUploadToken();
    const uploadUrl = result.getUploadUrl();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import deploy

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

try:
    result = client.pre_update_stack(
        deploy.PreUpdateStackRequest()
            .with_stack_name('stack-0001')
    )
    upload_token = result.upload_token
    upload_url = result.upload_url
except core.Gs2Exception as e:
    exit(1)
client = gs2('deploy')

api_result = client.pre_update_stack({
    stackName="stack-0001",
})

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

result = api_result.result
uploadToken = result.uploadToken;
uploadUrl = result.uploadUrl;
client = gs2('deploy')

api_result_handler = client.pre_update_stack_async({
    stackName="stack-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
uploadToken = result.uploadToken;
uploadUrl = result.uploadUrl;

updateStack

スタックを更新

新しいテンプレートと説明で既存のスタックを更新します。
更新するにはスタックが _COMPLETE ステータス(CREATE_COMPLETE、UPDATE_COMPLETE など)である必要があります。処理中のスタックを更新しようとするとエラーが返されます。
2つのモードをサポートしています:テンプレートをインラインで渡す ‘direct’ モードと、PreUpdateStack API で事前にアップロードしたテンプレートを使用する ‘preUpload’ モードです。
更新開始前に新しいテンプレートが検証されます。更新開始後、スタックは UPDATE_PROCESSING ステータスに入り、変更セットに従ってリソースが非同期で変更されます。

詳細

Request

有効化条件必須デフォルト値の制限説明
stackNamestring
~ 128文字スタック名
スタックを識別する一意な名前です。英数字および -(ハイフン) _(アンダースコア) .(ピリオド)で指定します。作成・更新・削除操作時にスタックを参照するために使用されます。
descriptionstring~ 1024文字説明文
mode文字列列挙型
enum {
  “direct”,
  “preUpload”
}
“direct”更新モード
定義説明
“direct”マスターデータを直接更新
“preUpload”マスターデータをアップロードしてから更新
templatestring{mode} == “direct”
✓※
~ 5242880文字テンプレートデータ
プロビジョニングする GS2 リソースを宣言的に定義する YAML または JSON ドキュメントです。GS2-Deploy は現在と以前のテンプレートの差分を検出し、必要に応じてリソースの作成・更新・削除を行います。最大サイズは 5 MB です。
※ mode が “direct” であれば必須
uploadTokenstring{mode} == “preUpload”
✓※
~ 1024文字事前アップロードで取得したトークン
アップロードしたマスターデータを適用するために使用されます。
※ mode が “preUpload” であれば必須

Result

説明
itemStack更新したスタック

実装例

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/deploy"
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 := deploy.Gs2DeployRestClient{
    Session: &session,
}
result, err := client.UpdateStack(
    &deploy.UpdateStackRequest {
        StackName: pointy.String("stack-0001"),
        Description: nil,
        Mode: nil,
        Template: pointy.String("\nGS2TemplateFormatVersion: \"2019-05-01\"\nDescription: Template Sample\n\nResources:\n  IdentifierAuthUser:\n    Type: GS2::Identifier::User\n    Properties:\n      Name: auth\n\nOutputs:\n  SecretKey: !GetAttr IdentifierAuthUser.Name\n"),
        UploadToken: nil,
    }
)
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\Deploy\Gs2DeployRestClient;
use Gs2\Deploy\Request\UpdateStackRequest;

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

$session->open();

$client = new Gs2DeployRestClient(
    $session
);

try {
    $result = $client->updateStack(
        (new UpdateStackRequest())
            ->withStackName("stack-0001")
            ->withDescription(null)
            ->withMode(null)
            ->withTemplate("\nGS2TemplateFormatVersion: \"2019-05-01\"\nDescription: Template Sample\n\nResources:\n  IdentifierAuthUser:\n    Type: GS2::Identifier::User\n    Properties:\n      Name: auth\n\nOutputs:\n  SecretKey: !GetAttr IdentifierAuthUser.Name\n")
            ->withUploadToken(null)
    );
    $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.deploy.rest.Gs2DeployRestClient;
import io.gs2.deploy.request.UpdateStackRequest;
import io.gs2.deploy.result.UpdateStackResult;

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

try {
    UpdateStackResult result = client.updateStack(
        new UpdateStackRequest()
            .withStackName("stack-0001")
            .withDescription(null)
            .withMode(null)
            .withTemplate("\nGS2TemplateFormatVersion: \"2019-05-01\"\nDescription: Template Sample\n\nResources:\n  IdentifierAuthUser:\n    Type: GS2::Identifier::User\n    Properties:\n      Name: auth\n\nOutputs:\n  SecretKey: !GetAttr IdentifierAuthUser.Name\n")
            .withUploadToken(null)
    );
    Stack item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}
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 Gs2DeployRestClient(session);

AsyncResult<Gs2.Gs2Deploy.Result.UpdateStackResult> asyncResult = null;
yield return client.UpdateStack(
    new Gs2.Gs2Deploy.Request.UpdateStackRequest()
        .WithStackName("stack-0001")
        .WithDescription(null)
        .WithMode(null)
        .WithTemplate("\nGS2TemplateFormatVersion: \"2019-05-01\"\nDescription: Template Sample\n\nResources:\n  IdentifierAuthUser:\n    Type: GS2::Identifier::User\n    Properties:\n      Name: auth\n\nOutputs:\n  SecretKey: !GetAttr IdentifierAuthUser.Name\n")
        .WithUploadToken(null),
    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 Gs2Deploy from '@/gs2/deploy';

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

try {
    const result = await client.updateStack(
        new Gs2Deploy.UpdateStackRequest()
            .withStackName("stack-0001")
            .withDescription(null)
            .withMode(null)
            .withTemplate("\nGS2TemplateFormatVersion: \"2019-05-01\"\nDescription: Template Sample\n\nResources:\n  IdentifierAuthUser:\n    Type: GS2::Identifier::User\n    Properties:\n      Name: auth\n\nOutputs:\n  SecretKey: !GetAttr IdentifierAuthUser.Name\n")
            .withUploadToken(null)
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import deploy

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

try:
    result = client.update_stack(
        deploy.UpdateStackRequest()
            .with_stack_name('stack-0001')
            .with_description(None)
            .with_mode(None)
            .with_template('\nGS2TemplateFormatVersion: "2019-05-01"\nDescription: Template Sample\n\nResources:\n  IdentifierAuthUser:\n    Type: GS2::Identifier::User\n    Properties:\n      Name: auth\n\nOutputs:\n  SecretKey: !GetAttr IdentifierAuthUser.Name\n')
            .with_upload_token(None)
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('deploy')

api_result = client.update_stack({
    stackName="stack-0001",
    description=nil,
    mode=nil,
    template="\nGS2TemplateFormatVersion: \"2019-05-01\"\nDescription: Template Sample\n\nResources:\n  IdentifierAuthUser:\n    Type: GS2::Identifier::User\n    Properties:\n      Name: auth\n\nOutputs:\n  SecretKey: !GetAttr IdentifierAuthUser.Name\n",
    uploadToken=nil,
})

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

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

api_result_handler = client.update_stack_async({
    stackName="stack-0001",
    description=nil,
    mode=nil,
    template="\nGS2TemplateFormatVersion: \"2019-05-01\"\nDescription: Template Sample\n\nResources:\n  IdentifierAuthUser:\n    Type: GS2::Identifier::User\n    Properties:\n      Name: auth\n\nOutputs:\n  SecretKey: !GetAttr IdentifierAuthUser.Name\n",
    uploadToken=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;

preChangeSet

変更セットの取得を準備(事前アップロード)

変更内容をプレビューするための新しいテンプレートファイルをアップロードするためのアップロードトークンと署名付き URL を取得します。
テンプレートが 1MB を超える場合、この3フェーズのフローが必要です:1) この API を呼び出してアップロード URL を取得、2) テンプレートを URL にアップロード、3) preUpload モードでアップロードトークンを指定して ChangeSet を呼び出し。
署名付き URL の有効期限は60分です。

詳細

Request

有効化条件必須デフォルト値の制限説明
stackNamestring
~ 128文字スタック名
スタックを識別する一意な名前です。英数字および -(ハイフン) _(アンダースコア) .(ピリオド)で指定します。作成・更新・削除操作時にスタックを参照するために使用されます。

Result

説明
uploadTokenstringアップロード後に結果を反映する際に使用するトークン
uploadUrlstringアップロード処理の実行に使用するURL

実装例

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/deploy"
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 := deploy.Gs2DeployRestClient{
    Session: &session,
}
result, err := client.PreChangeSet(
    &deploy.PreChangeSetRequest {
        StackName: pointy.String("stack-0001"),
    }
)
if err != nil {
    panic("error occurred")
}
uploadToken := result.UploadToken
uploadUrl := result.UploadUrl
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Deploy\Gs2DeployRestClient;
use Gs2\Deploy\Request\PreChangeSetRequest;

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

$session->open();

$client = new Gs2DeployRestClient(
    $session
);

try {
    $result = $client->preChangeSet(
        (new PreChangeSetRequest())
            ->withStackName("stack-0001")
    );
    $uploadToken = $result->getUploadToken();
    $uploadUrl = $result->getUploadUrl();
} 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.deploy.rest.Gs2DeployRestClient;
import io.gs2.deploy.request.PreChangeSetRequest;
import io.gs2.deploy.result.PreChangeSetResult;

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

try {
    PreChangeSetResult result = client.preChangeSet(
        new PreChangeSetRequest()
            .withStackName("stack-0001")
    );
    String uploadToken = result.getUploadToken();
    String uploadUrl = result.getUploadUrl();
} catch (Gs2Exception e) {
    System.exit(1);
}
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 Gs2DeployRestClient(session);

AsyncResult<Gs2.Gs2Deploy.Result.PreChangeSetResult> asyncResult = null;
yield return client.PreChangeSet(
    new Gs2.Gs2Deploy.Request.PreChangeSetRequest()
        .WithStackName("stack-0001"),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var uploadToken = result.UploadToken;
var uploadUrl = result.UploadUrl;
import Gs2Core from '@/gs2/core';
import * as Gs2Deploy from '@/gs2/deploy';

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

try {
    const result = await client.preChangeSet(
        new Gs2Deploy.PreChangeSetRequest()
            .withStackName("stack-0001")
    );
    const uploadToken = result.getUploadToken();
    const uploadUrl = result.getUploadUrl();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import deploy

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

try:
    result = client.pre_change_set(
        deploy.PreChangeSetRequest()
            .with_stack_name('stack-0001')
    )
    upload_token = result.upload_token
    upload_url = result.upload_url
except core.Gs2Exception as e:
    exit(1)
client = gs2('deploy')

api_result = client.pre_change_set({
    stackName="stack-0001",
})

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

result = api_result.result
uploadToken = result.uploadToken;
uploadUrl = result.uploadUrl;
client = gs2('deploy')

api_result_handler = client.pre_change_set_async({
    stackName="stack-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
uploadToken = result.uploadToken;
uploadUrl = result.uploadUrl;

changeSet

変更セットを取得

現在のスタックテンプレートと新しいテンプレートを比較し、適用される変更のリストを返します。
これにより、実際に更新を実行する前に影響をプレビューできます。
2つのモードをサポートしています:テンプレートをインラインで渡す ‘direct’ モードと、PreChangeSet API で事前にアップロードしたテンプレートを使用する ‘preUpload’ モードです。
返される変更セットには、作成、更新、削除されるリソースがそれぞれリストされます。

詳細

Request

有効化条件必須デフォルト値の制限説明
stackNamestring
~ 128文字スタック名
スタックを識別する一意な名前です。英数字および -(ハイフン) _(アンダースコア) .(ピリオド)で指定します。作成・更新・削除操作時にスタックを参照するために使用されます。
mode文字列列挙型
enum {
  “direct”,
  “preUpload”
}
“direct”更新モード
定義説明
“direct”マスターデータを直接更新
“preUpload”マスターデータをアップロードしてから更新
templatestring{mode} == “direct”
✓※
~ 5242880文字テンプレートデータ
プロビジョニングする GS2 リソースを宣言的に定義する YAML または JSON ドキュメントです。GS2-Deploy は現在と以前のテンプレートの差分を検出し、必要に応じてリソースの作成・更新・削除を行います。最大サイズは 5 MB です。
※ mode が “direct” であれば必須
uploadTokenstring{mode} == “preUpload”
✓※
~ 1024文字事前アップロードで取得したトークン
アップロードしたマスターデータを適用するために使用されます。
※ mode が “preUpload” であれば必須

Result

説明
itemsList<ChangeSet>スタックのリスト

実装例

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/deploy"
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 := deploy.Gs2DeployRestClient{
    Session: &session,
}
result, err := client.ChangeSet(
    &deploy.ChangeSetRequest {
        StackName: pointy.String("stack-0001"),
        Mode: nil,
        Template: pointy.String("\nGS2TemplateFormatVersion: \"2019-05-01\"\nDescription: Template Sample\n\nResources:\n  IdentifierAuthUser:\n    Type: GS2::Identifier::User\n    Properties:\n      Name: auth\n\nOutputs:\n  SecretKey: !GetAttr IdentifierAuthUser.Name\n"),
        UploadToken: nil,
    }
)
if err != nil {
    panic("error occurred")
}
items := result.Items
use Gs2\Core\Model\BasicGs2Credential;
use Gs2\Core\Model\Region;
use Gs2\Core\Net\Gs2RestSession;
use Gs2\Core\Exception\Gs2Exception;
use Gs2\Deploy\Gs2DeployRestClient;
use Gs2\Deploy\Request\ChangeSetRequest;

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

$session->open();

$client = new Gs2DeployRestClient(
    $session
);

try {
    $result = $client->changeSet(
        (new ChangeSetRequest())
            ->withStackName("stack-0001")
            ->withMode(null)
            ->withTemplate("\nGS2TemplateFormatVersion: \"2019-05-01\"\nDescription: Template Sample\n\nResources:\n  IdentifierAuthUser:\n    Type: GS2::Identifier::User\n    Properties:\n      Name: auth\n\nOutputs:\n  SecretKey: !GetAttr IdentifierAuthUser.Name\n")
            ->withUploadToken(null)
    );
    $items = $result->getItems();
} 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.deploy.rest.Gs2DeployRestClient;
import io.gs2.deploy.request.ChangeSetRequest;
import io.gs2.deploy.result.ChangeSetResult;

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

try {
    ChangeSetResult result = client.changeSet(
        new ChangeSetRequest()
            .withStackName("stack-0001")
            .withMode(null)
            .withTemplate("\nGS2TemplateFormatVersion: \"2019-05-01\"\nDescription: Template Sample\n\nResources:\n  IdentifierAuthUser:\n    Type: GS2::Identifier::User\n    Properties:\n      Name: auth\n\nOutputs:\n  SecretKey: !GetAttr IdentifierAuthUser.Name\n")
            .withUploadToken(null)
    );
    List<ChangeSet> items = result.getItems();
} catch (Gs2Exception e) {
    System.exit(1);
}
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 Gs2DeployRestClient(session);

AsyncResult<Gs2.Gs2Deploy.Result.ChangeSetResult> asyncResult = null;
yield return client.ChangeSet(
    new Gs2.Gs2Deploy.Request.ChangeSetRequest()
        .WithStackName("stack-0001")
        .WithMode(null)
        .WithTemplate("\nGS2TemplateFormatVersion: \"2019-05-01\"\nDescription: Template Sample\n\nResources:\n  IdentifierAuthUser:\n    Type: GS2::Identifier::User\n    Properties:\n      Name: auth\n\nOutputs:\n  SecretKey: !GetAttr IdentifierAuthUser.Name\n")
        .WithUploadToken(null),
    r => asyncResult = r
);
if (asyncResult.Error != null) {
    throw asyncResult.Error;
}
var result = asyncResult.Result;
var items = result.Items;
import Gs2Core from '@/gs2/core';
import * as Gs2Deploy from '@/gs2/deploy';

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

try {
    const result = await client.changeSet(
        new Gs2Deploy.ChangeSetRequest()
            .withStackName("stack-0001")
            .withMode(null)
            .withTemplate("\nGS2TemplateFormatVersion: \"2019-05-01\"\nDescription: Template Sample\n\nResources:\n  IdentifierAuthUser:\n    Type: GS2::Identifier::User\n    Properties:\n      Name: auth\n\nOutputs:\n  SecretKey: !GetAttr IdentifierAuthUser.Name\n")
            .withUploadToken(null)
    );
    const items = result.getItems();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import deploy

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

try:
    result = client.change_set(
        deploy.ChangeSetRequest()
            .with_stack_name('stack-0001')
            .with_mode(None)
            .with_template('\nGS2TemplateFormatVersion: "2019-05-01"\nDescription: Template Sample\n\nResources:\n  IdentifierAuthUser:\n    Type: GS2::Identifier::User\n    Properties:\n      Name: auth\n\nOutputs:\n  SecretKey: !GetAttr IdentifierAuthUser.Name\n')
            .with_upload_token(None)
    )
    items = result.items
except core.Gs2Exception as e:
    exit(1)
client = gs2('deploy')

api_result = client.change_set({
    stackName="stack-0001",
    mode=nil,
    template="\nGS2TemplateFormatVersion: \"2019-05-01\"\nDescription: Template Sample\n\nResources:\n  IdentifierAuthUser:\n    Type: GS2::Identifier::User\n    Properties:\n      Name: auth\n\nOutputs:\n  SecretKey: !GetAttr IdentifierAuthUser.Name\n",
    uploadToken=nil,
})

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

result = api_result.result
items = result.items;
client = gs2('deploy')

api_result_handler = client.change_set_async({
    stackName="stack-0001",
    mode=nil,
    template="\nGS2TemplateFormatVersion: \"2019-05-01\"\nDescription: Template Sample\n\nResources:\n  IdentifierAuthUser:\n    Type: GS2::Identifier::User\n    Properties:\n      Name: auth\n\nOutputs:\n  SecretKey: !GetAttr IdentifierAuthUser.Name\n",
    uploadToken=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;

updateStackFromGitHub

GitHub からスタックを更新

GitHub リポジトリから新しいテンプレートを直接取得して、既存のスタックを更新します。
更新するにはスタックが _COMPLETE ステータスである必要があります。
チェックアウト設定には、テンプレートのリポジトリ、ブランチまたはタグ、ファイルパスを指定します。
取得したテンプレートは更新開始前に検証されます。

詳細

Request

有効化条件必須デフォルト値の制限説明
stackNamestring
~ 128文字スタック名
スタックを識別する一意な名前です。英数字および -(ハイフン) _(アンダースコア) .(ピリオド)で指定します。作成・更新・削除操作時にスタックを参照するために使用されます。
descriptionstring~ 1024文字説明文
checkoutSettingGitHubCheckoutSetting
GitHubからテンプレートファイルをチェックアウトしてくる設定

Result

説明
itemStack更新したスタック

実装例

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/deploy"
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 := deploy.Gs2DeployRestClient{
    Session: &session,
}
result, err := client.UpdateStackFromGitHub(
    &deploy.UpdateStackFromGitHubRequest {
        StackName: pointy.String("stack-0001"),
        Description: nil,
        CheckoutSetting: &deploy.GitHubCheckoutSetting{
            ApiKeyId: pointy.String("apiKeyId-0001"),
            RepositoryName: pointy.String("gs2io/master-data"),
            SourcePath: pointy.String("path/to/file.json"),
            ReferenceType: pointy.String("branch"),
            BranchName: pointy.String("develop"),
        },
    }
)
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\Deploy\Gs2DeployRestClient;
use Gs2\Deploy\Request\UpdateStackFromGitHubRequest;

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

$session->open();

$client = new Gs2DeployRestClient(
    $session
);

try {
    $result = $client->updateStackFromGitHub(
        (new UpdateStackFromGitHubRequest())
            ->withStackName("stack-0001")
            ->withDescription(null)
            ->withCheckoutSetting((new GitHubCheckoutSetting())
                ->withApiKeyId("apiKeyId-0001")
                ->withRepositoryName("gs2io/master-data")
                ->withSourcePath("path/to/file.json")
                ->withReferenceType("branch")
                ->withBranchName("develop")
            )
    );
    $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.deploy.rest.Gs2DeployRestClient;
import io.gs2.deploy.request.UpdateStackFromGitHubRequest;
import io.gs2.deploy.result.UpdateStackFromGitHubResult;

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

try {
    UpdateStackFromGitHubResult result = client.updateStackFromGitHub(
        new UpdateStackFromGitHubRequest()
            .withStackName("stack-0001")
            .withDescription(null)
            .withCheckoutSetting(new GitHubCheckoutSetting()
                .withApiKeyId("apiKeyId-0001")
                .withRepositoryName("gs2io/master-data")
                .withSourcePath("path/to/file.json")
                .withReferenceType("branch")
                .withBranchName("develop")
            )
    );
    Stack item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}
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 Gs2DeployRestClient(session);

AsyncResult<Gs2.Gs2Deploy.Result.UpdateStackFromGitHubResult> asyncResult = null;
yield return client.UpdateStackFromGitHub(
    new Gs2.Gs2Deploy.Request.UpdateStackFromGitHubRequest()
        .WithStackName("stack-0001")
        .WithDescription(null)
        .WithCheckoutSetting(new Gs2.Gs2Deploy.Model.GitHubCheckoutSetting()
            .WithApiKeyId("apiKeyId-0001")
            .WithRepositoryName("gs2io/master-data")
            .WithSourcePath("path/to/file.json")
            .WithReferenceType("branch")
            .WithBranchName("develop")
        ),
    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 Gs2Deploy from '@/gs2/deploy';

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

try {
    const result = await client.updateStackFromGitHub(
        new Gs2Deploy.UpdateStackFromGitHubRequest()
            .withStackName("stack-0001")
            .withDescription(null)
            .withCheckoutSetting(new Gs2Deploy.model.GitHubCheckoutSetting()
                .withApiKeyId("apiKeyId-0001")
                .withRepositoryName("gs2io/master-data")
                .withSourcePath("path/to/file.json")
                .withReferenceType("branch")
                .withBranchName("develop")
            )
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import deploy

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

try:
    result = client.update_stack_from_git_hub(
        deploy.UpdateStackFromGitHubRequest()
            .with_stack_name('stack-0001')
            .with_description(None)
            .with_checkout_setting(deploy.GitHubCheckoutSetting()
                .with_api_key_id('apiKeyId-0001')
                .with_repository_name('gs2io/master-data')
                .with_source_path('path/to/file.json')
                .with_reference_type('branch')
                .with_branch_name('develop')
            )
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('deploy')

api_result = client.update_stack_from_git_hub({
    stackName="stack-0001",
    description=nil,
    checkoutSetting={
        api_key_id="apiKeyId-0001",
        repository_name="gs2io/master-data",
        source_path="path/to/file.json",
        reference_type="branch",
        branch_name="develop",
    },
})

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

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

api_result_handler = client.update_stack_from_git_hub_async({
    stackName="stack-0001",
    description=nil,
    checkoutSetting={
        api_key_id="apiKeyId-0001",
        repository_name="gs2io/master-data",
        source_path="path/to/file.json",
        reference_type="branch",
        branch_name="develop",
    },
})

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;

deleteStack

スタックを削除

スタックによって作成されたリソースの削除を行い、成功すればスタックエンティティを削除します。
削除するにはスタックが _COMPLETE ステータスである必要があります。
スタックが既に DELETE_COMPLETE ステータスの場合、スタックエンティティのみが削除されます。
それ以外の場合、スタックは DELETE_PROCESSING ステータスに入り、リソースのクリーンアップが非同期で開始されます。
何らかの理由でリソースの削除に失敗した場合、再試行または ForceDelete を使用できるよう、スタックエンティティが残ります。

詳細

Request

有効化条件必須デフォルト値の制限説明
stackNamestring
~ 128文字スタック名
スタックを識別する一意な名前です。英数字および -(ハイフン) _(アンダースコア) .(ピリオド)で指定します。作成・更新・削除操作時にスタックを参照するために使用されます。

Result

説明
itemStack削除したスタック

実装例

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/deploy"
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 := deploy.Gs2DeployRestClient{
    Session: &session,
}
result, err := client.DeleteStack(
    &deploy.DeleteStackRequest {
        StackName: pointy.String("stack-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\Deploy\Gs2DeployRestClient;
use Gs2\Deploy\Request\DeleteStackRequest;

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

$session->open();

$client = new Gs2DeployRestClient(
    $session
);

try {
    $result = $client->deleteStack(
        (new DeleteStackRequest())
            ->withStackName("stack-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.deploy.rest.Gs2DeployRestClient;
import io.gs2.deploy.request.DeleteStackRequest;
import io.gs2.deploy.result.DeleteStackResult;

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

try {
    DeleteStackResult result = client.deleteStack(
        new DeleteStackRequest()
            .withStackName("stack-0001")
    );
    Stack item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}
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 Gs2DeployRestClient(session);

AsyncResult<Gs2.Gs2Deploy.Result.DeleteStackResult> asyncResult = null;
yield return client.DeleteStack(
    new Gs2.Gs2Deploy.Request.DeleteStackRequest()
        .WithStackName("stack-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 Gs2Deploy from '@/gs2/deploy';

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

try {
    const result = await client.deleteStack(
        new Gs2Deploy.DeleteStackRequest()
            .withStackName("stack-0001")
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import deploy

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

try:
    result = client.delete_stack(
        deploy.DeleteStackRequest()
            .with_stack_name('stack-0001')
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('deploy')

api_result = client.delete_stack({
    stackName="stack-0001",
})

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

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

api_result_handler = client.delete_stack_async({
    stackName="stack-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;

forceDeleteStack

スタックを強制削除

現在のステータスやリソースの残存に関係なく、スタックエンティティを強制的に削除します。
通常の Delete API とは異なり、スタックが作成したリソースのクリーンアップは行いません。
残存するリソースは孤立状態となり、手動で管理する必要があります。
通常の削除プロセスが失敗した場合やスタックが回復不能な状態に陥った場合の最終手段として使用してください。

詳細

Request

有効化条件必須デフォルト値の制限説明
stackNamestring
~ 128文字スタック名
スタックを識別する一意な名前です。英数字および -(ハイフン) _(アンダースコア) .(ピリオド)で指定します。作成・更新・削除操作時にスタックを参照するために使用されます。

Result

説明
itemStack削除したスタック

実装例

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/deploy"
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 := deploy.Gs2DeployRestClient{
    Session: &session,
}
result, err := client.ForceDeleteStack(
    &deploy.ForceDeleteStackRequest {
        StackName: pointy.String("stack-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\Deploy\Gs2DeployRestClient;
use Gs2\Deploy\Request\ForceDeleteStackRequest;

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

$session->open();

$client = new Gs2DeployRestClient(
    $session
);

try {
    $result = $client->forceDeleteStack(
        (new ForceDeleteStackRequest())
            ->withStackName("stack-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.deploy.rest.Gs2DeployRestClient;
import io.gs2.deploy.request.ForceDeleteStackRequest;
import io.gs2.deploy.result.ForceDeleteStackResult;

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

try {
    ForceDeleteStackResult result = client.forceDeleteStack(
        new ForceDeleteStackRequest()
            .withStackName("stack-0001")
    );
    Stack item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}
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 Gs2DeployRestClient(session);

AsyncResult<Gs2.Gs2Deploy.Result.ForceDeleteStackResult> asyncResult = null;
yield return client.ForceDeleteStack(
    new Gs2.Gs2Deploy.Request.ForceDeleteStackRequest()
        .WithStackName("stack-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 Gs2Deploy from '@/gs2/deploy';

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

try {
    const result = await client.forceDeleteStack(
        new Gs2Deploy.ForceDeleteStackRequest()
            .withStackName("stack-0001")
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import deploy

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

try:
    result = client.force_delete_stack(
        deploy.ForceDeleteStackRequest()
            .with_stack_name('stack-0001')
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('deploy')

api_result = client.force_delete_stack({
    stackName="stack-0001",
})

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

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

api_result_handler = client.force_delete_stack_async({
    stackName="stack-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;

deleteStackResources

スタックのリソースを削除

スタックエンティティとテンプレートを保持しつつ、スタックが作成したリソースのみを削除します。
空のテンプレートでスタックを更新するのと同様の動作で、スタックは DELETE_PROCESSING ステータスに入り、リソースのクリーンアップが非同期で開始されます。
元のテンプレートがスタックエンティティに残るため、同じテンプレートまたは新しいテンプレートでスタックを再度更新することでリソースを復元できます。これにより、誤操作時の完全なスタック削除よりも安全な代替手段となります。

詳細

Request

有効化条件必須デフォルト値の制限説明
stackNamestring
~ 128文字スタック名
スタックを識別する一意な名前です。英数字および -(ハイフン) _(アンダースコア) .(ピリオド)で指定します。作成・更新・削除操作時にスタックを参照するために使用されます。

Result

説明
itemStackリソースを削除したスタック

実装例

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/deploy"
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 := deploy.Gs2DeployRestClient{
    Session: &session,
}
result, err := client.DeleteStackResources(
    &deploy.DeleteStackResourcesRequest {
        StackName: pointy.String("stack-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\Deploy\Gs2DeployRestClient;
use Gs2\Deploy\Request\DeleteStackResourcesRequest;

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

$session->open();

$client = new Gs2DeployRestClient(
    $session
);

try {
    $result = $client->deleteStackResources(
        (new DeleteStackResourcesRequest())
            ->withStackName("stack-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.deploy.rest.Gs2DeployRestClient;
import io.gs2.deploy.request.DeleteStackResourcesRequest;
import io.gs2.deploy.result.DeleteStackResourcesResult;

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

try {
    DeleteStackResourcesResult result = client.deleteStackResources(
        new DeleteStackResourcesRequest()
            .withStackName("stack-0001")
    );
    Stack item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}
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 Gs2DeployRestClient(session);

AsyncResult<Gs2.Gs2Deploy.Result.DeleteStackResourcesResult> asyncResult = null;
yield return client.DeleteStackResources(
    new Gs2.Gs2Deploy.Request.DeleteStackResourcesRequest()
        .WithStackName("stack-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 Gs2Deploy from '@/gs2/deploy';

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

try {
    const result = await client.deleteStackResources(
        new Gs2Deploy.DeleteStackResourcesRequest()
            .withStackName("stack-0001")
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import deploy

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

try:
    result = client.delete_stack_resources(
        deploy.DeleteStackResourcesRequest()
            .with_stack_name('stack-0001')
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('deploy')

api_result = client.delete_stack_resources({
    stackName="stack-0001",
})

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

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

api_result_handler = client.delete_stack_resources_async({
    stackName="stack-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;

deleteStackEntity

スタックを最終削除

すべてのリソースが正常にクリーンアップされた後、スタックエンティティを削除します。
通常、スタックリソースの削除(Clean)API が完了し、スタックが DELETE_COMPLETE ステータスになった後に使用します。
スタックにまだ残存リソースがある場合はエラーが返されます。先にスタックリソースの削除 API を使用してリソースを除去してください。

詳細

Request

有効化条件必須デフォルト値の制限説明
stackNamestring
~ 128文字スタック名
スタックを識別する一意な名前です。英数字および -(ハイフン) _(アンダースコア) .(ピリオド)で指定します。作成・更新・削除操作時にスタックを参照するために使用されます。

Result

説明
itemStack削除したスタック

実装例

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/deploy"
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 := deploy.Gs2DeployRestClient{
    Session: &session,
}
result, err := client.DeleteStackEntity(
    &deploy.DeleteStackEntityRequest {
        StackName: pointy.String("stack-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\Deploy\Gs2DeployRestClient;
use Gs2\Deploy\Request\DeleteStackEntityRequest;

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

$session->open();

$client = new Gs2DeployRestClient(
    $session
);

try {
    $result = $client->deleteStackEntity(
        (new DeleteStackEntityRequest())
            ->withStackName("stack-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.deploy.rest.Gs2DeployRestClient;
import io.gs2.deploy.request.DeleteStackEntityRequest;
import io.gs2.deploy.result.DeleteStackEntityResult;

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

try {
    DeleteStackEntityResult result = client.deleteStackEntity(
        new DeleteStackEntityRequest()
            .withStackName("stack-0001")
    );
    Stack item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}
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 Gs2DeployRestClient(session);

AsyncResult<Gs2.Gs2Deploy.Result.DeleteStackEntityResult> asyncResult = null;
yield return client.DeleteStackEntity(
    new Gs2.Gs2Deploy.Request.DeleteStackEntityRequest()
        .WithStackName("stack-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 Gs2Deploy from '@/gs2/deploy';

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

try {
    const result = await client.deleteStackEntity(
        new Gs2Deploy.DeleteStackEntityRequest()
            .withStackName("stack-0001")
    );
    const item = result.getItem();
} catch (e) {
    process.exit(1);
}
from gs2 import core
from gs2 import deploy

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

try:
    result = client.delete_stack_entity(
        deploy.DeleteStackEntityRequest()
            .with_stack_name('stack-0001')
    )
    item = result.item
except core.Gs2Exception as e:
    exit(1)
client = gs2('deploy')

api_result = client.delete_stack_entity({
    stackName="stack-0001",
})

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

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

api_result_handler = client.delete_stack_entity_async({
    stackName="stack-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

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

詳細

Request

Request parameters: None

Result

説明
itemstringバージョン

実装例

import "github.com/gs2io/gs2-golang-sdk/core"
import "github.com/gs2io/gs2-golang-sdk/deploy"
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 := deploy.Gs2DeployRestClient{
    Session: &session,
}
result, err := client.GetServiceVersion(
    &deploy.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\Deploy\Gs2DeployRestClient;
use Gs2\Deploy\Request\GetServiceVersionRequest;

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

$session->open();

$client = new Gs2DeployRestClient(
    $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.deploy.rest.Gs2DeployRestClient;
import io.gs2.deploy.request.GetServiceVersionRequest;
import io.gs2.deploy.result.GetServiceVersionResult;

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

try {
    GetServiceVersionResult result = client.getServiceVersion(
        new GetServiceVersionRequest()
    );
    String item = result.getItem();
} catch (Gs2Exception e) {
    System.exit(1);
}
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 Gs2DeployRestClient(session);

AsyncResult<Gs2.Gs2Deploy.Result.GetServiceVersionResult> asyncResult = null;
yield return client.GetServiceVersion(
    new Gs2.Gs2Deploy.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 Gs2Deploy from '@/gs2/deploy';

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

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

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

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

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;
client = gs2('deploy')

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;