View Source Appwrite.Services.Teams (appwrite v0.1.6)

The Teams service allows you to group users of your project and to enable them to share read and write access to your project resources, such as database documents or storage files. Each user who creates a team becomes the team owner and can delegate the ownership role by inviting a new team member. Only team owners can invite new users to their team.

Status: In Testing

Summary

Functions

Link to this function

create(client, team_id, name, roles \\ nil)

View Source
@spec create(Appwrite.Utils.Client.t(), String.t(), String.t(), [String.t()] | nil) ::
  {:ok, Appwrite.Types.Team.t()}
  | {:error, Appwrite.Exceptions.AppwriteException.t()}

Create a new team.

The user who creates the team is automatically assigned as the owner.

Parameters

  • team_id (String.t()): Unique team ID.
  • name (String.t()): Name of the team.
  • roles (optional, [String.t()]): List of roles for the team.

Returns

  • {:ok, %Team{}} on success.
  • {:error, %AppwriteException{}} on failure.
Link to this function

create_membership(client, team_id, roles, email \\ nil, user_id \\ nil, phone \\ nil, url \\ nil, name \\ nil)

View Source
@spec create_membership(
  Appwrite.Utils.Client.t(),
  String.t(),
  [String.t()],
  String.t() | nil,
  String.t() | nil,
  String.t() | nil,
  String.t() | nil,
  String.t() | nil
) :: {:ok, Appwrite.Types.Membership.t()} | {:error, any()}

Create a new membership in a team.

Parameters:

  • team_id (string): Team ID.
  • roles (list of strings): Roles assigned to the member.
  • email (string, optional): Email address.
  • user_id (string, optional): User ID.
  • phone (string, optional): Phone number.
  • url (string, optional): Redirect URL.
  • name (string, optional): Member's name.

Returns:

  • Membership: Membership details.
@spec delete(Appwrite.Utils.Client.t(), String.t()) ::
  {:ok, map()} | {:error, Appwrite.Exceptions.AppwriteException.t()}

Delete a team by its ID.

Parameters

  • team_id (String.t()): Unique team ID.

Returns

  • {:ok, %{}} on success.
  • {:error, %AppwriteException{}} on failure.
Link to this function

delete_membership(client, team_id, membership_id)

View Source
@spec delete_membership(Appwrite.Utils.Client.t(), String.t(), String.t()) ::
  {:ok, map()} | {:error, any()}

Delete a team membership.

Parameters:

  • team_id (string): Team ID.
  • membership_id (string): Membership ID.

Returns:

  • {}: Empty response.
@spec get(Appwrite.Utils.Client.t(), String.t()) ::
  {:ok, Appwrite.Types.Team.t()}
  | {:error, Appwrite.Exceptions.AppwriteException.t()}

Get team details by ID.

Parameters

  • team_id (String.t()): Unique team ID.

Returns

  • {:ok, %Team{}} on success.
  • {:error, %AppwriteException{}} on failure.
Link to this function

get_membership(client, team_id, membership_id)

View Source
@spec get_membership(Appwrite.Utils.Client.t(), String.t(), String.t()) ::
  {:ok, Appwrite.Types.Membership.t()} | {:error, any()}

Get a team membership by ID.

Parameters:

  • team_id (string): Team ID.
  • membership_id (string): Membership ID.

Returns:

  • Membership: Membership details.
Link to this function

get_prefs(client, team_id)

View Source
@spec get_prefs(Appwrite.Utils.Client.t(), String.t()) ::
  {:ok, Appwrite.Types.Preferences.t()} | {:error, any()}

Get team preferences.

Retrieves the shared preferences of a team by its unique ID.

Parameters:

  • client (Client): The Appwrite client instance.
  • team_id (String): The team ID.

Returns:

  • Preferences: Team preferences.
Link to this function

list(client, queries \\ nil, search \\ nil)

View Source
@spec list(Appwrite.Utils.Client.t(), [String.t()] | nil, String.t() | nil) ::
  {:ok, Appwrite.Types.TeamList.t()}
  | {:error, Appwrite.Exceptions.AppwriteException.t()}

List teams.

Fetches a list of all teams in which the current user is a member. Parameters can be used to filter the results.

Parameters

  • queries (optional, [String.t()]): List of query strings.
  • search (optional, String.t()): Search term.

Returns

  • {:ok, %TeamList{}} on success.
  • {:error, %AppwriteException{}} on failure.
Link to this function

list_memberships(client, team_id, queries \\ nil, search \\ nil)

View Source
@spec list_memberships(
  Appwrite.Utils.Client.t(),
  String.t(),
  [String.t()] | nil,
  String.t() | nil
) ::
  {:ok, Appwrite.Types.MembershipList.t()} | {:error, any()}

List team memberships.

Parameters:

  • team_id (string): Team ID.
  • queries (list of strings, optional): Query filters.
  • search (string, optional): Search keyword.

Returns:

  • MembershipList: A list of memberships.
Link to this function

update_membership(client, team_id, membership_id, roles)

View Source
@spec update_membership(Appwrite.Utils.Client.t(), String.t(), String.t(), [
  String.t()
]) ::
  {:ok, Appwrite.Types.Membership.t()} | {:error, any()}

Update a team membership's roles.

Parameters:

  • team_id (string): Team ID.
  • membership_id (string): Membership ID.
  • roles (list of strings): Updated roles.

Returns:

  • Membership: Updated membership details.
Link to this function

update_membership_status(client, team_id, membership_id, user_id, secret)

View Source
@spec update_membership_status(
  Appwrite.Utils.Client.t(),
  String.t(),
  String.t(),
  String.t(),
  String.t()
) :: {:ok, Appwrite.Types.Membership.t()} | {:error, any()}

Update team membership status.

Allows a user to accept an invitation to join a team after being redirected back to the app.

Parameters:

  • client (Client): The Appwrite client instance.
  • team_id (String): The team ID.
  • membership_id (String): The membership ID.
  • user_id (String): The user ID.
  • secret (String): The secret received via the invitation email.

Returns:

  • Membership: Updated membership details.
Link to this function

update_name(client, team_id, name)

View Source
@spec update_name(Appwrite.Utils.Client.t(), String.t(), String.t()) ::
  {:ok, Appwrite.Types.Team.t()}
  | {:error, Appwrite.Exceptions.AppwriteException.t()}

Update team name by ID.

Parameters

  • team_id (String.t()): Unique team ID.
  • name (String.t()): New name for the team.

Returns

  • {:ok, %Team{}} on success.
  • {:error, %AppwriteException{}} on failure.
Link to this function

update_prefs(client, team_id, prefs)

View Source
@spec update_prefs(Appwrite.Utils.Client.t(), String.t(), map()) ::
  {:ok, Appwrite.Types.Preferences.t()} | {:error, any()}

Update team preferences.

Updates the team's preferences. The new preferences replace any existing ones.

Parameters:

  • client (Client): The Appwrite client instance.
  • team_id (String): The team ID.
  • prefs (map): The preferences to update.

Returns:

  • Preferences: Updated team preferences.