HuggingfaceClient.Hub.Organizations (huggingface_client v0.1.0)

Copy Markdown View Source

HuggingFace Organization management.

Manage organization members, resource groups, billing, and settings.

Example

# List all orgs for the current user
{:ok, orgs} = HuggingfaceClient.list_my_orgs(access_token: "hf_...")
Enum.each(orgs, fn org -> IO.puts("#{org["name"]}: #{org["role"]}") end)

# Invite a user
:ok = HuggingfaceClient.invite_org_member("my-org",
  user: "alice",
  role: "write",
  access_token: "hf_..."
)

Summary

Functions

Creates a resource group (Enterprise feature).

Gets detailed information about an organization.

Invites a user to an organization.

Lists members of an organization.

Lists all organizations the authenticated user belongs to.

Lists resource groups for an organization (Enterprise feature).

Removes a member from an organization.

Updates a member's role in an organization.

Functions

create_resource_group(org, opts)

@spec create_resource_group(
  String.t(),
  keyword()
) :: {:ok, map()} | {:error, Exception.t()}

Creates a resource group (Enterprise feature).

Options

  • :name — resource group name (required)
  • :access_token

info(org, opts \\ [])

@spec info(
  String.t(),
  keyword()
) :: {:ok, map()} | {:error, Exception.t()}

Gets detailed information about an organization.

invite_member(org, opts)

@spec invite_member(
  String.t(),
  keyword()
) :: :ok | {:error, Exception.t()}

Invites a user to an organization.

Options

  • :user — username to invite (required)
  • :role — role: "read", "write", "admin" (default: "read")
  • :access_token

Example

:ok = HuggingfaceClient.invite_org_member("my-org",
  user: "alice",
  role: "write",
  access_token: "hf_..."
)

list_members(org, opts \\ [])

@spec list_members(
  String.t(),
  keyword()
) :: {:ok, [map()]} | {:error, Exception.t()}

Lists members of an organization.

Options

  • :role — filter by role: "admin", "write", "read", "contributor"
  • :access_token

Example

{:ok, members} = HuggingfaceClient.list_org_members("huggingface",
  access_token: "hf_..."
)
Enum.each(members, fn m -> IO.puts("#{m["user"]["name"]}: #{m["role"]}") end)

list_mine(opts \\ [])

@spec list_mine(keyword()) :: {:ok, [map()]} | {:error, Exception.t()}

Lists all organizations the authenticated user belongs to.

Example

{:ok, orgs} = HuggingfaceClient.Hub.Organizations.list_mine(access_token: "hf_...")
Enum.each(orgs, fn org -> IO.puts(org["name"]) end)

list_resource_groups(org, opts \\ [])

@spec list_resource_groups(
  String.t(),
  keyword()
) :: {:ok, [map()]} | {:error, Exception.t()}

Lists resource groups for an organization (Enterprise feature).

Resource groups allow fine-grained access control over repos, buckets, and other resources.

Example

{:ok, groups} = HuggingfaceClient.Hub.Organizations.list_resource_groups("my-enterprise-org",
  access_token: "hf_..."
)

remove_member(org, opts)

@spec remove_member(
  String.t(),
  keyword()
) :: :ok | {:error, Exception.t()}

Removes a member from an organization.

Example

:ok = HuggingfaceClient.remove_org_member("my-org",
  user: "alice",
  access_token: "hf_..."
)

update_member_role(org, opts)

@spec update_member_role(
  String.t(),
  keyword()
) :: :ok | {:error, Exception.t()}

Updates a member's role in an organization.

Options

  • :user — username (required)
  • :role — new role: "read", "write", "admin" (required)
  • :access_token