Packages
REST API Generated with swagger-codegen using the OpsGenie OpenAPI Specification.
Current section
Files
Jump to
Current section
Files
lib/ops_genie_restapi/api/user.ex
# NOTE: This class is auto generated by the swagger code generator program.
# https://github.com/swagger-api/swagger-codegen.git
# Do not edit the class manually.
defmodule OpsGenieRESTAPI.Api.User do
@moduledoc """
API calls for all endpoints tagged `User`.
"""
alias OpsGenieRESTAPI.Connection
import OpsGenieRESTAPI.RequestBuilder
@doc """
Create User
Creates a user with the given payload
## Parameters
- connection (OpsGenieRESTAPI.Connection): Connection to server
- body (CreateUserPayload): Request payload of the user object
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, %OpsGenieRESTAPI.Model.SuccessResponse{}} on success
{:error, info} on failure
"""
@spec create_user(Tesla.Env.client, OpsGenieRESTAPI.Model.CreateUserPayload.t, keyword()) :: {:ok, OpsGenieRESTAPI.Model.SuccessResponse.t} | {:error, Tesla.Env.t}
def create_user(connection, body, _opts \\ []) do
%{}
|> method(:post)
|> url("/v2/users")
|> add_param(:body, :"body", body)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> decode(%OpsGenieRESTAPI.Model.SuccessResponse{})
end
@doc """
Delete User
Delete user with the given identifier
## Parameters
- connection (OpsGenieRESTAPI.Connection): Connection to server
- identifier (String.t): Identifier of the user to be searched
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, %OpsGenieRESTAPI.Model.SuccessResponse{}} on success
{:error, info} on failure
"""
@spec delete_user(Tesla.Env.client, String.t, keyword()) :: {:ok, OpsGenieRESTAPI.Model.SuccessResponse.t} | {:error, Tesla.Env.t}
def delete_user(connection, identifier, _opts \\ []) do
%{}
|> method(:delete)
|> url("/v2/users/#{identifier}")
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> decode(%OpsGenieRESTAPI.Model.SuccessResponse{})
end
@doc """
Get User
Get user for the given identifier
## Parameters
- connection (OpsGenieRESTAPI.Connection): Connection to server
- identifier (String.t): Identifier of the user to be searched
- opts (KeywordList): [optional] Optional parameters
- :expand ([String.t]): Comma separated list of strings to create a more detailed response. The only expandable field for user api is 'contact'
## Returns
{:ok, %OpsGenieRESTAPI.Model.GetUserResponse{}} on success
{:error, info} on failure
"""
@spec get_user(Tesla.Env.client, String.t, keyword()) :: {:ok, OpsGenieRESTAPI.Model.GetUserResponse.t} | {:error, Tesla.Env.t}
def get_user(connection, identifier, opts \\ []) do
optional_params = %{
:"expand" => :query
}
%{}
|> method(:get)
|> url("/v2/users/#{identifier}")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> decode(%OpsGenieRESTAPI.Model.GetUserResponse{})
end
@doc """
List User Escalations
List escalations of the user for the given identifier
## Parameters
- connection (OpsGenieRESTAPI.Connection): Connection to server
- identifier (String.t): Identifier of the user to be searched
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, %OpsGenieRESTAPI.Model.ListUserEscalationsResponse{}} on success
{:error, info} on failure
"""
@spec list_user_escalations(Tesla.Env.client, String.t, keyword()) :: {:ok, OpsGenieRESTAPI.Model.ListUserEscalationsResponse.t} | {:error, Tesla.Env.t}
def list_user_escalations(connection, identifier, _opts \\ []) do
%{}
|> method(:get)
|> url("/v2/users/#{identifier}/escalations")
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> decode(%OpsGenieRESTAPI.Model.ListUserEscalationsResponse{})
end
@doc """
List User Forwarding Rules
List user forwarding rules for the given user identifier
## Parameters
- connection (OpsGenieRESTAPI.Connection): Connection to server
- identifier (String.t): Identifier of the user to be searched
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, %OpsGenieRESTAPI.Model.ListUserForwardingRulesResponse{}} on success
{:error, info} on failure
"""
@spec list_user_forwarding_rules(Tesla.Env.client, String.t, keyword()) :: {:ok, OpsGenieRESTAPI.Model.ListUserForwardingRulesResponse.t} | {:error, Tesla.Env.t}
def list_user_forwarding_rules(connection, identifier, _opts \\ []) do
%{}
|> method(:get)
|> url("/v2/users/#{identifier}/forwarding-rules")
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> decode(%OpsGenieRESTAPI.Model.ListUserForwardingRulesResponse{})
end
@doc """
List User Schedules
List schedules of the user for the given identifier
## Parameters
- connection (OpsGenieRESTAPI.Connection): Connection to server
- identifier (String.t): Identifier of the user to be searched
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, %OpsGenieRESTAPI.Model.ListUserSchedulesResponse{}} on success
{:error, info} on failure
"""
@spec list_user_schedules(Tesla.Env.client, String.t, keyword()) :: {:ok, OpsGenieRESTAPI.Model.ListUserSchedulesResponse.t} | {:error, Tesla.Env.t}
def list_user_schedules(connection, identifier, _opts \\ []) do
%{}
|> method(:get)
|> url("/v2/users/#{identifier}/schedules")
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> decode(%OpsGenieRESTAPI.Model.ListUserSchedulesResponse{})
end
@doc """
List User Teams
List user teams for the given user identifier
## Parameters
- connection (OpsGenieRESTAPI.Connection): Connection to server
- identifier (String.t): Identifier of the user to be searched
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, %OpsGenieRESTAPI.Model.ListUserTeamsResponse{}} on success
{:error, info} on failure
"""
@spec list_user_teams(Tesla.Env.client, String.t, keyword()) :: {:ok, OpsGenieRESTAPI.Model.ListUserTeamsResponse.t} | {:error, Tesla.Env.t}
def list_user_teams(connection, identifier, _opts \\ []) do
%{}
|> method(:get)
|> url("/v2/users/#{identifier}/teams")
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> decode(%OpsGenieRESTAPI.Model.ListUserTeamsResponse{})
end
@doc """
List users
List users with given parameters
## Parameters
- connection (OpsGenieRESTAPI.Connection): Connection to server
- opts (KeywordList): [optional] Optional parameters
- :limit (integer()): Number of users to retrieve
- :offset (integer()): Number of users to skip from start
- :sort_field (String.t): Field to use in sorting. Should be one of 'username', 'fullName' and 'insertedAt'
- :order (String.t): Direction of sorting. Should be one of 'asc' or 'desc'
- :query (String.t): Field:value combinations with most of user fields to make more advanced searches. Possible fields are username, fullName, blocked, verified, role, locale, timeZone, userAddress and createdAt
## Returns
{:ok, %OpsGenieRESTAPI.Model.ListUsersResponse{}} on success
{:error, info} on failure
"""
@spec list_users(Tesla.Env.client, keyword()) :: {:ok, OpsGenieRESTAPI.Model.ListUsersResponse.t} | {:error, Tesla.Env.t}
def list_users(connection, opts \\ []) do
optional_params = %{
:"limit" => :query,
:"offset" => :query,
:"sortField" => :query,
:"order" => :query,
:"query" => :query
}
%{}
|> method(:get)
|> url("/v2/users")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> decode(%OpsGenieRESTAPI.Model.ListUsersResponse{})
end
@doc """
Update User (Partial)
Update user with the given identifier
## Parameters
- connection (OpsGenieRESTAPI.Connection): Connection to server
- identifier (String.t): Identifier of the user to be searched
- opts (KeywordList): [optional] Optional parameters
- :body (UpdateUserPayload): Request payload of the user object
## Returns
{:ok, %OpsGenieRESTAPI.Model.SuccessResponse{}} on success
{:error, info} on failure
"""
@spec update_user(Tesla.Env.client, String.t, keyword()) :: {:ok, OpsGenieRESTAPI.Model.SuccessResponse.t} | {:error, Tesla.Env.t}
def update_user(connection, identifier, opts \\ []) do
optional_params = %{
:"body" => :body
}
%{}
|> method(:patch)
|> url("/v2/users/#{identifier}")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> decode(%OpsGenieRESTAPI.Model.SuccessResponse{})
end
end