Aura.Orgs (Aura v1.0.1)
View SourceService module for interacting with Hex Organizations
Resources
- Hex
- Contact the maintainer (he's happy to help!)
Summary
Types
Options to modify an Orgs request
Functions
Adds a user to an org with a given role
Changes a user's role to new_role
Grabs an organization, given an org_name
Grabs an org member, given their org_name and username
Grabs a list of members to an organization, given an org_name
Lists all the organizations the requester can see
Removes a user from an org
Streams audit logs, scoped to an organization
Types
@type org_opts() :: [{:repo_url, Aura.Common.repo_url()}]
Options to modify an Orgs request
Keys
- repo_url ::
Aura.Common.repo_url/0
Functions
@spec add_org_member( org_name :: Aura.Common.org_name(), username :: Aura.Common.username(), role :: Aura.Model.HexOrgMember.role(), opts :: org_opts() ) :: {:ok, Aura.Model.HexOrgMember.t()} | {:error, any()}
Adds a user to an org with a given role
Parameters
Parameter | Description |
---|---|
org_name | Aura.Common.org_name/0 |
username | Aura.Common.username/0 |
role | Aura.Model.HexOrgMember.role/0 |
opts[:repo_url] | Aura.Common.repo_url/0 |
API Details
Method | Path | Controller | Action |
---|---|---|---|
POST | /orgs/:org_name /members | OrganizationUserController | :create |
@spec change_member_role( org_name :: Aura.Common.org_name(), username :: Aura.Common.username(), new_role :: Aura.Model.HexOrgMember.role(), opts :: org_opts() ) :: {:ok, Aura.Model.HexOrgMember.t()} | {:error, any()}
Changes a user's role to new_role
Parameters
Parameter | Description |
---|---|
org_name | Aura.Common.org_name/0 |
username | Aura.Common.username/0 |
new_role | Aura.Model.HexOrgMember.role/0 |
opts[:repo_url] | Aura.Common.repo_url/0 |
API Details
Method | Path | Controller | Action |
---|---|---|---|
POST | /orgs/:org_name /members/:username | OrganizationUserController | :update |
@spec get_org(org_name :: Aura.Common.org_name(), opts :: org_opts()) :: {:ok, Aura.Model.HexOrg.t()} | {:error, any()}
Grabs an organization, given an org_name
Parameters
Parameter | Description |
---|---|
org_name | Aura.Common.org_name/0 |
opts[:repo_url] | Aura.Common.repo_url/0 |
API Details
Method | Path | Controller | Action |
---|---|---|---|
GET | /orgs/:org_name | OrganizationController | :show |
Examples
iex> alias Aura.Orgs
iex> opts = [repo_url: "http://localhost:4000/api"]
iex> {:ok, org} = Orgs.get_org("test_org", opts)
iex> org.name
"test_org"
@spec get_org_member( org_name :: Aura.Common.org_name(), username :: Aura.Common.username(), opts :: org_opts() ) :: {:ok, Aura.Model.HexOrgMember.t()} | {:error, any()}
Grabs an org member, given their org_name and username
Parameters
Parameter | Description |
---|---|
org_name | Aura.Common.org_name/0 |
username | Aura.Common.username/0 |
opts[:repo_url] | Aura.Common.repo_url/0 |
API Details
Method | Path | Controller | Action |
---|---|---|---|
GET | /orgs/:org_name /members/:username | OrganizationUserController | :show |
Examples
iex> alias Aura.Orgs
iex> opts = [repo_url: "http://localhost:4000/api"]
iex> {:ok, member} = Orgs.get_org_member("test_org", "testuser", opts)
iex> member.username
"testuser"
@spec list_org_members(org_name :: Aura.Common.org_name(), opts :: org_opts()) :: {:ok, Aura.Model.HexOrgMember.t()} | {:error, any()}
Grabs a list of members to an organization, given an org_name
Parameters
Parameter | Description |
---|---|
org_name | Aura.Common.org_name/0 |
opts[:repo_url] | Aura.Common.repo_url/0 |
API Details
Method | Path | Controller | Action |
---|---|---|---|
GET | /orgs/:org_name /members | OrganizationUserController | :index |
Examples
iex> alias Aura.Orgs
iex> opts = [repo_url: "http://localhost:4000/api"]
iex> {:ok, members} = Orgs.list_org_members("test_org", opts)
iex> Enum.empty?(members)
false
@spec list_orgs(opts :: org_opts()) :: {:ok, [Aura.Model.HexOrg.t()]} | {:error, any()}
Lists all the organizations the requester can see
Parameters
Parameter | Description |
---|---|
opts[:repo_url] | Aura.Common.repo_url/0 |
API Details
Method | Path | Controller | Action |
---|---|---|---|
GET | /orgs | OrganizationController | :index |
Examples
iex> alias Aura.Orgs
iex> opts = [repo_url: "http://localhost:4000/api"]
iex> {:ok, orgs} = Orgs.list_orgs(opts)
iex> Enum.empty?(orgs)
false
@spec remove_org_member( org_name :: Aura.Common.org_name(), username :: Aura.Common.username(), opts :: org_opts() ) :: :ok | {:error, any()}
Removes a user from an org
Parameters
Parameter | Description |
---|---|
org_name | Aura.Common.org_name/0 |
username | Aura.Common.username/0 |
opts[:repo_url] | Aura.Common.repo_url/0 |
API Details
Method | Path | Controller | Action |
---|---|---|---|
DELETE | /orgs/:org_name /members/:username | OrganizationUserController | :delete |
@spec stream_audit_logs( org_name :: Aura.Common.org_name(), opts :: Aura.Common.audit_opts() ) :: Enumerable.t()
Streams audit logs, scoped to an organization
Note that the page size is fixed by the API to be 100 per page.
Parameters
Parameter | Description |
---|---|
org_name | Aura.Common.org_name/0 |
opts[:repo_url] | Aura.Common.repo_url/0 |
opts[:page] | Aura.Common.start_page/0 |
API Details
Method | Path | Controller | Action |
---|---|---|---|
GET | /orgs/:org_name /audit-logs | OrganizationController | :audit_logs |
Examples
iex> alias Aura.Orgs
iex> opts = [repo_url: "http://localhost:4000/api"]
iex> [first, _second] = Orgs.stream_audit_logs("test_org", opts) |> Enum.take(2)
iex> String.starts_with?(first.user_agent, "aura")
true