-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(kno-1566): add tenant functions (#12)
- Loading branch information
1 parent
213004e
commit aed2e0e
Showing
1 changed file
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |