メインコンテンツへスキップ
workspace は、アプリケーションを整理してチームメンバーと共同作業するための仕組みです。Client クラスを使って workspace の作成、取得、一覧表示、削除を行えます。

workspace の作成

client.create_workspaceWorkspace オブジェクトを返します。
import squarecloud as square

client = square.Client(api_key='API_KEY')

async def example():
    workspace = await client.create_workspace(name='My Workspace')
    
    print(workspace.id)              # Workspace identifier
    print(workspace.name)             # 'My Workspace'
    print(workspace.owner)            # Owner member information
    print(workspace.members)          # List of workspace members
    print(workspace.applications)     # List of applications in the workspace
    print(workspace.createdAt)        # Workspace creation timestamp

workspace の取得

client.get_workspaceWorkspace オブジェクトを返します。
import squarecloud as square

client = square.Client(api_key='API_KEY')

async def example():
    workspace = await client.get_workspace(workspace_id='WORKSPACE_ID')
    
    print(workspace.id)          # Workspace identifier
    print(workspace.name)         # Workspace name
    print(workspace.owner)        # Owner member information
    print(workspace.members)      # List of workspace members
    print(workspace.applications) # List of applications in the workspace

すべての workspace の一覧表示

client.all_workspacesWorkspace オブジェクトのリストを返します。
import squarecloud as square

client = square.Client(api_key='API_KEY')

async def example():
    workspaces = await client.all_workspaces()
    
    for workspace in workspaces:
        print(f"Workspace: {workspace.name} (ID: {workspace.id})")
        print(f"  Owner: {workspace.owner.name}")
        print(f"  Members: {len(workspace.members)}")
        print(f"  Applications: {len(workspace.applications)}")

workspace の削除

client.delete_workspaceResponse オブジェクトを返します。
import squarecloud as square

client = square.Client(api_key='API_KEY')

async def example():
    response = await client.delete_workspace(workspace_id='WORKSPACE_ID')
    print(f"Workspace deleted successfully: {response.status}")

workspace からの退出

workspace のメンバーであってもオーナーでない場合は、client.leave_workspace を使って workspace から退出できます。このメソッドは Response オブジェクトを返します。
import squarecloud as square

client = square.Client(api_key='API_KEY')

async def example():
    response = await client.leave_workspace(workspace_id='WORKSPACE_ID')
    print(f"Left workspace successfully: {response.status}")

workspace のデータ構造

Workspace オブジェクトには以下の情報が含まれます。
プロパティ説明
idstrworkspace の一意な識別子
namestrworkspace 名
ownerMemberworkspace のオーナー情報
memberslist[Member]workspace メンバーのリスト
applicationslist[Application]workspace に紐づくアプリケーション
createdAtstrworkspace の作成タイムスタンプ (ISO 8601)

Member のデータ構造

workspace 内の各メンバーは以下の構造を持ちます。
プロパティ説明
idstrメンバーの一意な識別子
namestrメンバーの表示名
groupstrworkspace 内でのメンバーの役割またはグループ