automation

package
v0.6.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 24, 2024 License: Apache-2.0 Imports: 8 Imported by: 6

Documentation

Overview

Package automation (api/clients/automation) provides a simple CRUD client for the Automations API. For a 'smart' API client see package clients/automation.

Index

Constants

This section is empty.

Variables

View Source
var Resources = map[ResourceType]Resource{
	Workflows:         {Path: "/platform/automation/v1/workflows"},
	BusinessCalendars: {Path: "/platform/automation/v1/business-calendars"},
	SchedulingRules:   {Path: "/platform/automation/v1/scheduling-rules"},
}

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client can be used to interact with the Automation API

func NewClient

func NewClient(client *rest.Client) *Client

NewClient creates and returns a new instance a client which is used for interacting with automation resources.

Parameters:

  • client: A REST client used for making HTTP requests to interact with automation resources.

Returns:

  • *Client: A new instance of the Client type initialized with the provided REST client and resources.

func (Client) Create

func (a Client) Create(ctx context.Context, resourceType ResourceType, data []byte) (result *http.Response, err error)

Create creates a new automation object based on the specified resource type.

Parameters:

  • ctx: The context for the HTTP request.
  • resourceType: The type of the resource to retrieve.
  • data: the data of the resource

Returns:

  • Response: A Response containing the result of the HTTP operation, including status code and data.
  • error: An error if the HTTP call fails or another error happened.

func (Client) Delete

func (a Client) Delete(ctx context.Context, resourceType ResourceType, id string) (*http.Response, error)

Delete removes an automation object of the specified resource type by its unique identifier (ID).

If the initial DELETE request results in a forbidden status code (HTTP 403) for Workflows, it retries the request without the "adminAccess" parameter.

Parameters:

  • ctx: A context.Context for controlling the request lifecycle.
  • resourceType: The type of resource from which to delete the object.
  • id: The unique identifier (ID) of the object to delete.

Returns:

  • Response: A Response containing the result of the HTTP operation, including status code and data.
  • error: An error if the HTTP call fails or another error happened.

func (Client) Get

func (a Client) Get(ctx context.Context, resourceType ResourceType, id string) (*http.Response, error)

Get retrieves a single automation object based on the specified resource type and ID. It makes a HTTP GET <resourceType endpoint>/<id> request against the API.

It checks if the ID is non-empty, and if not, returns an error.

Parameters:

  • ctx: The context for the HTTP request.
  • resourceType: The type of the resource to retrieve.
  • id: The unique identifier of the object to retrieve.

Returns:

  • Response: A Response containing the result of the HTTP operation, including status code and data.
  • error: An error if the HTTP call fails or another error happened.

func (Client) List

func (a Client) List(ctx context.Context, resourceType ResourceType, offset int) (*http.Response, error)

List retrieves makes a HTTP GET <resourceType endpoint>/ request against the API. The Automations API implements offset based pagination, which can be controlled by passing the desired offset to this method. Parsing responses and making several calls with the desired offset needs to be handled by the caller. See the 'smart' client implemented in clients/automation/Client for a List implementation that follows pagination automatically.

Parameters:

  • ctx: A context.Context for controlling the request lifecycle.
  • resourceType: The type of resource to list.
  • offset: The offset to start the paginated query from. This is passed directly to the API.

Returns:

  • ListResponse: A ListResponse which is an api.PagedListResponse containing all objects fetched from the api
  • error: An error if the HTTP call fails or another error happened.

func (Client) Update

func (a Client) Update(ctx context.Context, resourceType ResourceType, id string, data []byte) (*http.Response, error)

Update updates an automation object based on the specified resource type and id

Parameters:

  • ctx: The context for the HTTP request.
  • resourceType: The type of the resource to retrieve.
  • id: the id of the resource to be updated
  • data: the updated data

Returns:

  • Response: A Response containing the result of the HTTP operation, including status code and data.
  • error: An error if the HTTP call fails or another error happened.

type ClientOption

type ClientOption func(*Client)

ClientOption are (optional) additional parameter passed to the creation of an automation client

type Resource

type Resource struct {
	// Path is the API path to be used for this resource
	Path string
}

Resource specifies information about a specific resource

type ResourceType

type ResourceType int

ResourceType enumerates different kind of resources

const (
	Workflows ResourceType = iota
	BusinessCalendars
	SchedulingRules
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL