Packages

REST API Generated with swagger-codegen using the OpsGenie OpenAPI Specification.

Current section

Files

Jump to
ops_genie_restapi lib ops_genie_restapi api schedule.ex
Raw

lib/ops_genie_restapi/api/schedule.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.Schedule do
@moduledoc """
API calls for all endpoints tagged `Schedule`.
"""
alias OpsGenieRESTAPI.Connection
import OpsGenieRESTAPI.RequestBuilder
@doc """
Create Schedule
Creates a new schedule
## Parameters
- connection (OpsGenieRESTAPI.Connection): Connection to server
- body (CreateSchedulePayload): Request payload of created schedule
- opts (KeywordList): [optional] Optional parameters
## Returns
{:ok, %OpsGenieRESTAPI.Model.CreateScheduleResponse{}} on success
{:error, info} on failure
"""
@spec create_schedule(Tesla.Env.client, OpsGenieRESTAPI.Model.CreateSchedulePayload.t, keyword()) :: {:ok, OpsGenieRESTAPI.Model.CreateScheduleResponse.t} | {:error, Tesla.Env.t}
def create_schedule(connection, body, _opts \\ []) do
%{}
|> method(:post)
|> url("/v2/schedules")
|> add_param(:body, :"body", body)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> decode(%OpsGenieRESTAPI.Model.CreateScheduleResponse{})
end
@doc """
Delete Schedule
Delete schedule with given identifier
## Parameters
- connection (OpsGenieRESTAPI.Connection): Connection to server
- identifier (String.t): Identifier of schedule which could be id or name
- opts (KeywordList): [optional] Optional parameters
- :identifier_type (String.t): Type of the identifier that is provided as an in-line parameter. Possible values are 'id' or 'name'
## Returns
{:ok, %OpsGenieRESTAPI.Model.SuccessResponse{}} on success
{:error, info} on failure
"""
@spec delete_schedule(Tesla.Env.client, String.t, keyword()) :: {:ok, OpsGenieRESTAPI.Model.SuccessResponse.t} | {:error, Tesla.Env.t}
def delete_schedule(connection, identifier, opts \\ []) do
optional_params = %{
:"identifierType" => :query
}
%{}
|> method(:delete)
|> url("/v2/schedules/#{identifier}")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> decode(%OpsGenieRESTAPI.Model.SuccessResponse{})
end
@doc """
Export Schedule
Returns an .ics file as byte array
## Parameters
- connection (OpsGenieRESTAPI.Connection): Connection to server
- identifier (String.t): Identifier of schedule which could be id or name
- opts (KeywordList): [optional] Optional parameters
- :identifier_type (String.t): Type of the identifier that is provided as an in-line parameter. Possible values are 'id' or 'name'
## Returns
{:ok, %OpsGenieRESTAPI.Model.binary(){}} on success
{:error, info} on failure
"""
@spec export_schedule(Tesla.Env.client, String.t, keyword()) :: {:ok, String.t} | {:error, Tesla.Env.t}
def export_schedule(connection, identifier, opts \\ []) do
optional_params = %{
:"identifierType" => :query
}
%{}
|> method(:get)
|> url("/v2/schedules/#{identifier}.ics")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> decode(false)
end
@doc """
Get Schedule
Returns schedule with given id or name
## Parameters
- connection (OpsGenieRESTAPI.Connection): Connection to server
- identifier (String.t): Identifier of schedule which could be id or name
- opts (KeywordList): [optional] Optional parameters
- :identifier_type (String.t): Type of the identifier that is provided as an in-line parameter. Possible values are 'id' or 'name'
## Returns
{:ok, %OpsGenieRESTAPI.Model.GetScheduleResponse{}} on success
{:error, info} on failure
"""
@spec get_schedule(Tesla.Env.client, String.t, keyword()) :: {:ok, OpsGenieRESTAPI.Model.GetScheduleResponse.t} | {:error, Tesla.Env.t}
def get_schedule(connection, identifier, opts \\ []) do
optional_params = %{
:"identifierType" => :query
}
%{}
|> method(:get)
|> url("/v2/schedules/#{identifier}")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> decode(%OpsGenieRESTAPI.Model.GetScheduleResponse{})
end
@doc """
Get Schedule Timeline
Returns schedule timeline with given id or name
## Parameters
- connection (OpsGenieRESTAPI.Connection): Connection to server
- identifier (String.t): Identifier of schedule which could be id or name
- opts (KeywordList): [optional] Optional parameters
- :identifier_type (String.t): Type of the identifier that is provided as an in-line parameter. Possible values are 'id' or 'name'
- :expand ([String.t]): Returns more detailed response with expanding it. Possible values are 'base', 'forwarding', and 'override' which is also returned with expandable field of response
- :interval (integer()): Length of time as integer in intervalUnits to retrieve the timeline. Default value is 1
- :interval_unit (String.t): Unit of the time to retrieve the timeline. Available values are 'days', 'weeks' and 'months'. Default value is 'weeks'
- :date (DateTime.t): Time to return future date on-call participants. Default date is the moment of the time that request is received
## Returns
{:ok, %OpsGenieRESTAPI.Model.GetScheduleTimelineResponse{}} on success
{:error, info} on failure
"""
@spec get_schedule_timeline(Tesla.Env.client, String.t, keyword()) :: {:ok, OpsGenieRESTAPI.Model.GetScheduleTimelineResponse.t} | {:error, Tesla.Env.t}
def get_schedule_timeline(connection, identifier, opts \\ []) do
optional_params = %{
:"identifierType" => :query,
:"expand" => :query,
:"interval" => :query,
:"intervalUnit" => :query,
:"date" => :query
}
%{}
|> method(:get)
|> url("/v2/schedules/#{identifier}/timeline")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> decode(%OpsGenieRESTAPI.Model.GetScheduleTimelineResponse{})
end
@doc """
List Schedules
Returns list of schedule
## Parameters
- connection (OpsGenieRESTAPI.Connection): Connection to server
- opts (KeywordList): [optional] Optional parameters
- :expand ([String.t]): Returns more detailed response with expanding it. Possible value is 'rotation' which is also returned with expandable field of response
## Returns
{:ok, %OpsGenieRESTAPI.Model.ListSchedulesResponse{}} on success
{:error, info} on failure
"""
@spec list_schedules(Tesla.Env.client, keyword()) :: {:ok, OpsGenieRESTAPI.Model.ListSchedulesResponse.t} | {:error, Tesla.Env.t}
def list_schedules(connection, opts \\ []) do
optional_params = %{
:"expand" => :query
}
%{}
|> method(:get)
|> url("/v2/schedules")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> decode(%OpsGenieRESTAPI.Model.ListSchedulesResponse{})
end
@doc """
Update Schedule (Partial)
Update schedule with given id or name
## Parameters
- connection (OpsGenieRESTAPI.Connection): Connection to server
- identifier (String.t): Identifier of schedule which could be id or name
- opts (KeywordList): [optional] Optional parameters
- :identifier_type (String.t): Type of the identifier that is provided as an in-line parameter. Possible values are 'id' or 'name'
- :body (UpdateSchedulePayload): Request payload of update schedule action
## Returns
{:ok, %OpsGenieRESTAPI.Model.UpdateScheduleResponse{}} on success
{:error, info} on failure
"""
@spec update_schedule(Tesla.Env.client, String.t, keyword()) :: {:ok, OpsGenieRESTAPI.Model.UpdateScheduleResponse.t} | {:error, Tesla.Env.t}
def update_schedule(connection, identifier, opts \\ []) do
optional_params = %{
:"identifierType" => :query,
:"body" => :body
}
%{}
|> method(:patch)
|> url("/v2/schedules/#{identifier}")
|> add_optional_params(optional_params, opts)
|> Enum.into([])
|> (&Connection.request(connection, &1)).()
|> decode(%OpsGenieRESTAPI.Model.UpdateScheduleResponse{})
end
end