> ## Documentation Index
> Fetch the complete documentation index at: https://docs.squarecloud.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Gestione dei workspace

> In questa sezione imparerai a gestire i workspace utilizzando l'SDK Python. I workspace ti permettono di organizzare più applicazioni e collaborare con i membri del tuo team.

[Client]: client

I workspace sono un modo per organizzare le tue applicazioni e collaborare con i membri del team. Puoi creare, recuperare, elencare ed eliminare i workspace utilizzando la classe Client.

## Creazione di un workspace

`client.create_workspace` restituisce un oggetto `Workspace`.

```python theme={null}
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
```

## Recupero di un workspace

`client.get_workspace` restituisce un oggetto `Workspace`.

```python theme={null}
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
```

## Elenco di tutti i workspace

`client.all_workspaces` restituisce una lista di oggetti `Workspace`.

```python theme={null}
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)}")
```

## Eliminazione di un workspace

`client.delete_workspace` restituisce un oggetto `Response`.

```python theme={null}
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}")
```

## Abbandono di un workspace

Se sei un membro di un workspace ma non il proprietario, puoi abbandonare il workspace utilizzando `client.leave_workspace`, che restituisce un oggetto `Response`.

```python theme={null}
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}")
```

## Struttura dei dati del workspace

L'oggetto `Workspace` contiene le seguenti informazioni:

| Proprietà      | Tipo                | Descrizione                                     |
| -------------- | ------------------- | ----------------------------------------------- |
| `id`           | `str`               | Identificatore univoco del workspace            |
| `name`         | `str`               | Nome del workspace                              |
| `owner`        | `Member`            | Informazioni sul proprietario del workspace     |
| `members`      | `list[Member]`      | Lista dei membri del workspace                  |
| `applications` | `list[Application]` | Applicazioni associate al workspace             |
| `createdAt`    | `str`               | Timestamp di creazione del workspace (ISO 8601) |

## Struttura dei dati del membro

Ogni membro di un workspace ha la seguente struttura:

| Proprietà | Tipo  | Descrizione                             |
| --------- | ----- | --------------------------------------- |
| `id`      | `str` | Identificatore univoco del membro       |
| `name`    | `str` | Nome visualizzato del membro            |
| `group`   | `str` | Ruolo o gruppo del membro nel workspace |
