GcpGcs.Bucket (GcpGcs v0.2.0)

Copy Markdown View Source

Bucket operations for the Google Cloud Storage JSON API.

Responses are the decoded JSON Bucket resource as a map with string keys (e.g. %{"name" => ..., "location" => ...}).

These functions are exposed through the top-level GcpGcs module; call them there unless you need the focused namespace.

Summary

Functions

Creates a bucket in project_id.

Deletes a bucket. Returns :ok on success.

Gets a bucket's metadata.

Lists buckets in project_id.

Patches a bucket's metadata with attrs (a map of Bucket resource fields).

Functions

create(project_id, bucket, opts \\ [])

@spec create(String.t(), String.t(), keyword()) ::
  {:ok, map()} | {:error, GcpGcs.Error.t()}

Creates a bucket in project_id.

Options

  • :location — e.g. "US", "EU", "us-central1"
  • :storage_class — e.g. "STANDARD", "NEARLINE", "COLDLINE", "ARCHIVE"
  • :predefined_acl — e.g. "private", "publicRead"
  • :attrs — a map of any additional Bucket resource fields, merged into the request body
  • :timeout — request timeout in ms

delete(bucket, opts \\ [])

@spec delete(
  String.t(),
  keyword()
) :: :ok | {:error, GcpGcs.Error.t()}

Deletes a bucket. Returns :ok on success.

get(bucket, opts \\ [])

@spec get(
  String.t(),
  keyword()
) :: {:ok, map()} | {:error, GcpGcs.Error.t()}

Gets a bucket's metadata.

list(project_id, opts \\ [])

@spec list(
  String.t(),
  keyword()
) ::
  {:ok, %{items: list(), next_page_token: String.t() | nil}}
  | {:error, GcpGcs.Error.t()}

Lists buckets in project_id.

Options

  • :prefix — filter results to names starting with this prefix
  • :page_size — maximum results per page (maps to maxResults)
  • :page_token — pagination token

Returns {:ok, %{items: [...], next_page_token: token}}.

update(bucket, attrs, opts \\ [])

@spec update(String.t(), map(), keyword()) ::
  {:ok, map()} | {:error, GcpGcs.Error.t()}

Patches a bucket's metadata with attrs (a map of Bucket resource fields).