# Organization

> The team workspaces of the NoClick app you're in, as its workspace settings show them.

```python
acme = noclick.Organization.create("Acme Ops")
noclick.Organization.invite(acme, "sam@example.com", role="admin")
for member in noclick.Organization.members(acme):
    print(member["email"], member["role"])
```

A team workspace's members are people, so every call is a signed-in person's own: a client holding a person's
session token (never a key, which refuses them all). Not `noclick.Workspace`, which is one of Work's spaces.
Members, invites and single sign-on come back as the API answers them (dicts).

## noclick.Organization

```python
class Organization
```

A team workspace you're in.

| Attribute | Type | Description |
| --- | --- | --- |
| `id` | `str` |  |
| `name` | `str` |  |
| `slug` | `str` |  |
| `role` | `str | None` | Your role in it: `owner`, `admin` or `member`. |
| `icon_url` | `str | None` |  |
| `raw` | `dict[str, Any]` | The response JSON exactly as the API sent it. |

### Organization.list

```python
noclick.Organization.list(*, client=None) -> list[Organization]
```

The team workspaces you're in, each with your `role`.

Parameters:

- `client` (`Client | None`, default `None`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: `list[Organization]` Each team workspace you're in, as an `Organization`.

Usage:

```python
for workspace in noclick.Organization.list():
    print(workspace.name, workspace.role)
```

### Organization.get

```python
noclick.Organization.get(organization, *, client=None) -> Organization
```

One you're in, by id.

Parameters:

- `organization` (`Any`, required)
- `client` (`Client | None`, default `None`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: `Organization` The `Organization`.

Usage:

```python
print(noclick.Organization.get("8c1f…").name)
```

### Organization.create

```python
noclick.Organization.create(name, *, slug=None, client=None) -> Organization
```

Make a team workspace with you as its owner (`slug` made from the name when left out); your session acts
in it from then on. How many you may own is your plan's.

Parameters:

- `name` (`str`, required)
- `slug` (`str | None`, default `None`)
- `client` (`Client | None`, default `None`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: `Organization` The new `Organization`.

Usage:

```python
acme = noclick.Organization.create("Acme Ops")
```

### Organization.update

```python
noclick.Organization.update(
    organization, *, name=None, settings=None, client=None
) -> dict[str, Any]
```

Rename it or change its settings (its owner or an admin).

Parameters:

- `organization` (`Any`, required)
- `name` (`str | None`, default `None`)
- `settings` (`dict[str, Any] | None`, default `None`)
- `client` (`Client | None`, default `None`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: `dict[str, Any]` The team workspace as it now stands.

Usage:

```python
noclick.Organization.update(acme, name="Acme Operations")
```

### Organization.delete

```python
noclick.Organization.delete(organization, *, client=None) -> None
```

Delete it for good, its members and invites with it (its owner only).

Parameters:

- `organization` (`Any`, required)
- `client` (`Client | None`, default `None`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Usage:

```python
noclick.Organization.delete(acme)
```

### Organization.slug_available

```python
noclick.Organization.slug_available(slug, *, client=None) -> bool
```

Whether a new team workspace could take `slug`.

Parameters:

- `slug` (`str`, required)
- `client` (`Client | None`, default `None`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: `bool` `True` when no team workspace has it.

Usage:

```python
print(noclick.Organization.slug_available("acme-ops"))
```

### Organization.members

```python
noclick.Organization.members(organization, *, client=None) -> list[dict[str, Any]]
```

Its members, each with their `user_id`, `email` and `role`.

Parameters:

- `organization` (`Any`, required)
- `client` (`Client | None`, default `None`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: `list[dict[str, Any]]` Each member, with their `user_id`, `email`, `full_name` and `role`.

Usage:

```python
print([m["email"] for m in noclick.Organization.members(acme)])
```

### Organization.invite

```python
noclick.Organization.invite(
    organization, email, *, role='member', client=None
) -> dict[str, Any]
```

Invite someone by email (its owner or an admin): they're emailed a link that joins them as `role`
(`admin` or `member`). How many people it holds is its plan's.

Parameters:

- `organization` (`Any`, required)
- `email` (`str`, required)
- `role` (`str`, default `'member'`)
- `client` (`Client | None`, default `None`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: `dict[str, Any]` The invite, with `email_sent`: `False` when its email couldn't go (`email_error` says why), and the
invite stands all the same, so share its link yourself.

Usage:

```python
noclick.Organization.invite(acme, "sam@example.com", role="admin")
```

### Organization.set_role

```python
noclick.Organization.set_role(organization, user_id, role, *, client=None) -> None
```

Change a member's role (its owner or an admin; never the owner's).

Parameters:

- `organization` (`Any`, required)
- `user_id` (`str`, required)
- `role` (`str`, required)
- `client` (`Client | None`, default `None`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Usage:

```python
noclick.Organization.set_role(acme, "6a0b…", "admin")
```

### Organization.remove_member

```python
noclick.Organization.remove_member(organization, user_id, *, client=None) -> None
```

Take a member out (its owner or an admin; never the owner).

Parameters:

- `organization` (`Any`, required)
- `user_id` (`str`, required)
- `client` (`Client | None`, default `None`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Usage:

```python
noclick.Organization.remove_member(acme, "6a0b…")
```

### Organization.transfer

```python
noclick.Organization.transfer(organization, user_id, *, client=None) -> None
```

Hand it to another of its members (its owner only): they become its owner, you an admin.

Parameters:

- `organization` (`Any`, required)
- `user_id` (`str`, required)
- `client` (`Client | None`, default `None`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Usage:

```python
noclick.Organization.transfer(acme, "6a0b…")
```

### Organization.invites

```python
noclick.Organization.invites(organization, *, client=None) -> list[dict[str, Any]]
```

Its invites still waiting to be accepted.

Parameters:

- `organization` (`Any`, required)
- `client` (`Client | None`, default `None`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: `list[dict[str, Any]]` Each invite still waiting, with its `email`, `role` and when it expires.

Usage:

```python
print([i["email"] for i in noclick.Organization.invites(acme)])
```

### Organization.revoke_invite

```python
noclick.Organization.revoke_invite(organization, invite_id, *, client=None) -> None
```

Call an invite off: its link stops working.

Parameters:

- `organization` (`Any`, required)
- `invite_id` (`str`, required)
- `client` (`Client | None`, default `None`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Usage:

```python
noclick.Organization.revoke_invite(acme, "c3d4…")
```

### Organization.accept_invite

```python
noclick.Organization.accept_invite(token, *, client=None) -> dict[str, Any]
```

Join the team workspace an invite to your email asks you to.

Parameters:

- `token` (`str`, required)
- `client` (`Client | None`, default `None`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: `dict[str, Any]` The `organization_id` and `organization_name` of the team workspace you joined.

Usage:

```python
noclick.Organization.accept_invite(token)
```

### Organization.switch_to

```python
noclick.Organization.switch_to(organization, *, client=None) -> None
```

Make the workspace your session acts in a team one you're in, or your own (`None`).

Parameters:

- `organization` (`Any`, required)
- `client` (`Client | None`, default `None`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Usage:

```python
noclick.Organization.switch_to(None)
```
