ExLLM.Providers.Gemini.Permissions (ex_llm v0.8.1)

View Source

Google Gemini Permissions API implementation.

This module provides functionality for managing permissions on tuned models and corpora in the Gemini API. Permissions control access levels (reader, writer, owner) for users, groups, or everyone.

Summary

Functions

Creates a permission for a tuned model or corpus.

Deletes a permission.

Gets information about a specific permission.

Lists permissions for a tuned model or corpus.

Transfers ownership of a tuned model.

Updates a permission's role.

Types

grantee_type()

@type grantee_type() :: :GRANTEE_TYPE_UNSPECIFIED | :USER | :GROUP | :EVERYONE

options()

@type options() :: [
  api_key: String.t(),
  oauth_token: String.t(),
  config_provider: module(),
  page_size: integer(),
  page_token: String.t(),
  update_mask: String.t()
]

role()

@type role() :: :ROLE_UNSPECIFIED | :READER | :WRITER | :OWNER

Functions

create_permission(parent, permission, opts \\ [])

@spec create_permission(String.t(), map(), options()) ::
  {:ok, ExLLM.Providers.Gemini.Permissions.Permission.t()} | {:error, term()}

Creates a permission for a tuned model or corpus.

Parameters

  • parent - The parent resource (e.g., "tunedModels/my-model" or "corpora/my-corpus")
  • permission - The permission to create containing:
    • :grantee_type - Type of grantee (USER, GROUP, or EVERYONE)
    • :email_address - Email for USER or GROUP types
    • :role - Permission level (READER, WRITER, or OWNER)
  • opts - Options including :api_key

Returns

  • {:ok, permission} - The created permission
  • {:error, reason} - Error details

delete_permission(name, opts \\ [])

@spec delete_permission(String.t(), options()) :: {:ok, map()} | {:error, term()}

Deletes a permission.

Parameters

  • name - The resource name of the permission
  • opts - Options including :api_key

Returns

  • {:ok, %{}} - Empty response on success
  • {:error, reason} - Error details

get_permission(name, opts \\ [])

@spec get_permission(String.t(), options()) ::
  {:ok, ExLLM.Providers.Gemini.Permissions.Permission.t()} | {:error, term()}

Gets information about a specific permission.

Parameters

  • name - The resource name (e.g., "tunedModels/my-model/permissions/perm-123")
  • opts - Options including :api_key

Returns

  • {:ok, permission} - The permission details
  • {:error, reason} - Error details

list_permissions(parent, opts \\ [])

@spec list_permissions(String.t(), options()) ::
  {:ok, ExLLM.Providers.Gemini.Permissions.ListPermissionsResponse.t()}
  | {:error, term()}

Lists permissions for a tuned model or corpus.

Parameters

  • parent - The parent resource
  • opts - Options including:
    • :api_key - Google API key
    • :page_size - Maximum number of permissions to return
    • :page_token - Token for pagination

Returns

  • {:ok, response} - List of permissions
  • {:error, reason} - Error details

transfer_ownership(name, request, opts \\ [])

@spec transfer_ownership(String.t(), map(), options()) ::
  {:ok, map()} | {:error, term()}

Transfers ownership of a tuned model.

The current owner will be downgraded to writer role.

Parameters

  • name - The resource name of the tuned model
  • request - Map containing :email_address of new owner
  • opts - Options including :api_key

Returns

  • {:ok, %{}} - Empty response on success
  • {:error, reason} - Error details

update_permission(name, update, opts \\ [])

@spec update_permission(String.t(), map(), options()) ::
  {:ok, ExLLM.Providers.Gemini.Permissions.Permission.t()} | {:error, term()}

Updates a permission's role.

Parameters

  • name - The resource name of the permission
  • update - Map containing :role to update
  • opts - Options including:
    • :api_key - Google API key
    • :update_mask - Required field mask (should be "role")

Returns

  • {:ok, permission} - The updated permission
  • {:error, reason} - Error details