Zum Hauptinhalt springen
Workspaces sind eine Möglichkeit, deine Anwendungen zu organisieren und mit Teammitgliedern zusammenzuarbeiten. Du kannst Workspaces mit der Client-Klasse erstellen, abrufen, auflisten und löschen.

Einen Workspace erstellen

client.create_workspace gibt ein Workspace-Objekt zurück.
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

Einen Workspace abrufen

client.get_workspace gibt ein Workspace-Objekt zurück.
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

Alle Workspaces auflisten

client.all_workspaces gibt eine Liste von Workspace-Objekten zurück.
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)}")

Einen Workspace löschen

client.delete_workspace gibt ein Response-Objekt zurück.
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}")

Einen Workspace verlassen

Wenn du Mitglied eines Workspace bist, aber nicht der Eigentümer, kannst du den Workspace mit client.leave_workspace verlassen, was ein Response-Objekt zurückgibt.
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-Datenstruktur

Das Workspace-Objekt enthält die folgenden Informationen:
PropertyTypBeschreibung
idstrEindeutiger Workspace-Identifikator
namestrName des Workspace
ownerMemberInformationen zum Workspace-Eigentümer
memberslist[Member]Liste der Workspace-Mitglieder
applicationslist[Application]Mit dem Workspace verknüpfte Anwendungen
createdAtstrZeitstempel der Workspace-Erstellung (ISO 8601)

Member-Datenstruktur

Jedes Mitglied in einem Workspace hat die folgende Struktur:
PropertyTypBeschreibung
idstrEindeutiger Mitglieds-Identifikator
namestrAnzeigename des Mitglieds
groupstrRolle oder Gruppe des Mitglieds im Workspace