Skip to content

Commit

Permalink
chore(kno-1566): add tenant functions (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
meryldakin authored Jul 18, 2022
1 parent 213004e commit aed2e0e
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions lib/knock/resources/tenants.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
defmodule Knock.Tenants do
@moduledoc """
Knock resources for accessing Tenants
"""
alias Knock.Api
alias Knock.Client

@doc """
Upserts the given tenant with the tenant data provided.
"""
@spec set(Client.t(), String.t(), map()) :: Api.response()
def set(client, id, tenant_data) do
Api.put(client, "/tenants/#{id}", tenant_data)
end

@doc """
Gets the given tenant.
"""
@spec get(Client.t(), String.t()) :: Api.response()
def get(client, id) do
Api.get(client, "/tenants/#{id}")
end

@doc """
Deletes the given tenant.
"""
@spec delete(Client.t(), String.t()) :: Api.response()
def delete(client, id) do
Api.delete(client, "/tenants/#{id}")
end

@doc """
Returns paginated tenants for environment
# Available optional parameters:
#
# - page_size: specify size of the page to be returned by the api. (max limit: 50)
# - after: after cursor for pagination
# - before: before cursor for pagination
# - tenant_id: id of the tenant to filter for
# - name: name of the tenant to filter for
"""

@spec list(Client.t(), Keyword.t()) :: Api.response()
def list(client, options \\ []) do
Api.get(client, "/tenants", query: options)
end
end

0 comments on commit aed2e0e

Please sign in to comment.