rokka

package
v0.0.0-...-5dd6c5c Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2022 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package rokka contains the API client for rokka.io.

Documentation of the API itself can be found on https://rokka.io/documentation/.

Example
c := NewClient(&Config{
	APIKey: "exampleAPIKey",
})

resp, err := c.GetOrganization("example")
if err != nil {
	fmt.Println(err)
	os.Exit(1)
}
fmt.Printf("%s", resp.ID)
Output:

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func BoolPtr

func BoolPtr(v bool) *bool

BoolPtr returns a pointer to the passed bool

func Float64Ptr

func Float64Ptr(v float64) *float64

Float64Ptr returns a pointer to the passed float64

func IntPtr

func IntPtr(v int) *int

IntPtr returns a pointer to the passed int

func StrPtr

func StrPtr(v string) *string

StrPtr returns a pointer to the passed string

Types

type APIError

type APIError struct {
	Error struct {
		Code    int    `json:"code"`
		Message string `json:"message"`
	} `json:"error"`
}

APIError is returned by the API in case of errors.

type AddframesOperation

type AddframesOperation struct {
	Delay   *float64 `json:"delay,omitempty"`
	Enabled *bool    `json:"enabled,omitempty"`
	Frames  *string  `json:"frames,omitempty"`
}

AddframesOperation is an auto-generated Operation as specified by the rokka API.

See: https://rokka.io/documentation/references/operations.html

func (AddframesOperation) Name

func (o AddframesOperation) Name() string

Name implements rokka.Operation.Name

func (AddframesOperation) Validate

func (o AddframesOperation) Validate() (bool, error)

Validate implements rokka.Operation.Validate.

type AlphaOperation

type AlphaOperation struct {
	Enabled *bool   `json:"enabled,omitempty"`
	Mode    *string `json:"mode,omitempty"`
	Opacity *int    `json:"opacity,omitempty"`
}

AlphaOperation is an auto-generated Operation as specified by the rokka API.

See: https://rokka.io/documentation/references/operations.html

func (AlphaOperation) Name

func (o AlphaOperation) Name() string

Name implements rokka.Operation.Name

func (AlphaOperation) Validate

func (o AlphaOperation) Validate() (bool, error)

Validate implements rokka.Operation.Validate.

type AnnotatedUnmarshalTypeError

type AnnotatedUnmarshalTypeError struct {
	*json.UnmarshalTypeError
	Content string
}

AnnotatedUnmarshalTypeError is a wrapper for json.UnmarshalTypeError adding the offending JSON body around the offset.

func (*AnnotatedUnmarshalTypeError) Error

Error returns the same error as UnmarshalTypeError.

type AutorotateOperation

type AutorotateOperation struct {
	Enabled           *bool   `json:"enabled,omitempty"`
	Height            *int    `json:"height,omitempty"`
	RotationDirection *string `json:"rotation_direction,omitempty"`
	Width             *int    `json:"width,omitempty"`
}

AutorotateOperation is an auto-generated Operation as specified by the rokka API.

See: https://rokka.io/documentation/references/operations.html

func (AutorotateOperation) Name

func (o AutorotateOperation) Name() string

Name implements rokka.Operation.Name

func (AutorotateOperation) Validate

func (o AutorotateOperation) Validate() (bool, error)

Validate implements rokka.Operation.Validate.

type BlurOperation

type BlurOperation struct {
	Enabled *bool    `json:"enabled,omitempty"`
	Sigma   *float64 `json:"sigma,omitempty"`
}

BlurOperation is an auto-generated Operation as specified by the rokka API. Calling .Validate() will return false if required properties are missing.

See: https://rokka.io/documentation/references/operations.html

func (BlurOperation) Name

func (o BlurOperation) Name() string

Name implements rokka.Operation.Name

func (BlurOperation) Validate

func (o BlurOperation) Validate() (bool, error)

Validate implements rokka.Operation.Validate.

type Client

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

Client used to communicate with the rokka API.

func NewClient

func NewClient(config *Config) (c *Client)

NewClient returns a new client

func (*Client) AddDynamicMetadata

func (c *Client) AddDynamicMetadata(org, hash, name string, data io.Reader, options DynamicMetadataOptions) (DynamicMetadataResponse, error)

AddDynamicMetadata updates a source image by adding arbitrary metadata. Rokka generates a new image hash when calling this function. The return value of this call contains the location of the new image. If deletePrevious is true, the previous image will be deleted.

See: https://rokka.io/documentation/references/dynamic-metadata.html

func (*Client) AutoRetry

func (c *Client) AutoRetry() *Client

AutoRetry returns a client with automatic retries in case of failures enabled. By default this is the retryingHTTPClient which does max 10 retries in these cases:

  • a 429, 502, or 503 response is encountered
  • a client connection error is encountered

The return value is a copy of the Client. This can be either stored in a separate variable or used directly, e.g.:

cl := rokka.NewClient(&rokka.Config{})
cl.AutoRetry().GetOrganization("example")

By following the pattern outlined in `http.go`, an own, more tailored retry pattern can be implemented if needed. When instantiating the rokka client such a specific implementation can be passed to the config as RetryingHTTPClient.

AutoRetry is safe for concurrent use because it returns a copy of the client.

func (*Client) Call

func (c *Client) Call(req *http.Request, v interface{}, rh responseHandler) error

Call executes an HTTP request. It automatically adds the Api-Version and Api-Key headers to the request. If the response contains a status code >= 400 a StatusCodeError is returned.

func (*Client) CallJSONResponse

func (c *Client) CallJSONResponse(req *http.Request, v interface{}) error

CallJSONResponse is using Client.Call and automatically converts the response to JSON.

func (*Client) CopySourceImage

func (c *Client) CopySourceImage(sourceOrg, hash string, destinationOrg string) error

CopySourceImage copies a source image by hash from one org to another

See: https://rokka.io/documentation/references/source-images.html

func (*Client) CopySourceImages

func (c *Client) CopySourceImages(sourceOrg string, hashes []string, destinationOrg string) (int, int, error)

CopySourceImages copies a multiple source images by hashes from one org to another

See: https://rokka.io/documentation/references/source-images.html

func (*Client) CreateMembership

func (c *Client) CreateMembership(org, userid string, roles []MembershipRole) error

CreateMembership creates a membership for a given UUID of the user.

See: https://rokka.io/documentation/references/users-and-memberships.html#assign-a-user-to-an-organization

func (*Client) CreateNewMembershipWithCurrentUser

func (c *Client) CreateNewMembershipWithCurrentUser(org string, roles []MembershipRole) (Membership, error)

CreateNewMembershipWithCurrentUser creates a new user object and automatically assign it to an organisation

See: https://rokka.io/documentation/references/users-and-memberships.html#create-a-new-user-object-and-automatically-assign-it-to-an-organisation

func (*Client) CreateOrganization

func (c *Client) CreateOrganization(name, billingEmail, displayName string) (OrganizationResponse, error)

CreateOrganization can be used to create a new organization which is bound to the API key (user) you supplied.

See: https://rokka.io/documentation/references/organizations.html#create-an-organization

func (*Client) CreateSourceImage

func (c *Client) CreateSourceImage(org, name string, data io.Reader) (CreateSourceImageResponse, error)

CreateSourceImage uploads an image without user or dynamic metadata set.

See: https://rokka.io/documentation/references/source-images.html#create-a-source-image

func (*Client) CreateSourceImageWithMetadata

func (c *Client) CreateSourceImageWithMetadata(org, name string, data io.Reader, userMetadata, dynamicMetadata map[string]interface{}) (CreateSourceImageResponse, error)

CreateSourceImageWithMetadata uploads an image.

See: https://rokka.io/documentation/references/source-images.html#create-a-source-image

func (*Client) CreateStack

func (c *Client) CreateStack(org, name string, stack CreateStackRequest, overwrite bool) (Stack, error)

CreateStack allows to create a new stack for the organization.

See: https://rokka.io/documentation/references/stacks.html

func (*Client) CreateUser

func (c *Client) CreateUser(org, email string) (CreateUserResponse, error)

CreateUser creates a new organization and a user with the given email address.

See: https://rokka.io/documentation/references/users-and-memberships.html#create-a-user

func (*Client) CreateUserWithoutOrg

func (c *Client) CreateUserWithoutOrg(email string) (CreateUserResponse, error)

CreateUserWithoutOrg creates a user with the given email address.

See: https://rokka.io/documentation/references/users-and-memberships.html#create-a-user

func (*Client) DeleteDynamicMetadata

func (c *Client) DeleteDynamicMetadata(org, hash, name string, options DynamicMetadataOptions) (DynamicMetadataResponse, error)

DeleteDynamicMetadata updates a source image by deleting existing metadata. Rokka generates a new image hash when calling this function. The return value of this call contains the location of the new image. If deletePrevious is true, the previous image will be deleted.

See: https://rokka.io/documentation/references/dynamic-metadata.html

func (*Client) DeleteMembership

func (c *Client) DeleteMembership(org string, uuid string) error

DeleteMembership deletes a user from an organization

See: https://rokka.io/documentation/references/users-and-memberships.html#remove-a-user-from-an-organization

func (*Client) DeleteSourceImage

func (c *Client) DeleteSourceImage(org, hash string) error

DeleteSourceImage removes a source image by hash.

See: https://rokka.io/documentation/references/source-images.html

func (*Client) DeleteSourceImageByBinaryHash

func (c *Client) DeleteSourceImageByBinaryHash(org, binaryHash string) error

DeleteSourceImageByBinaryHash removes a source image by binaryhash.

See: https://rokka.io/documentation/references/source-images.html

func (*Client) DeleteStack

func (c *Client) DeleteStack(org, name string) error

DeleteStack allows to delete an existing stack.

See: https://rokka.io/documentation/references/stacks.html

func (*Client) DeleteUserMetadata

func (c *Client) DeleteUserMetadata(org, hash string) error

DeleteUserMetadata updates a source image by deleting existing metadata.

See: https://rokka.io/documentation/references/image-metadata.html

func (*Client) DeleteUserMetadataByName

func (c *Client) DeleteUserMetadataByName(org, hash, name string) error

DeleteUserMetadataByName updates a source image by removing user metadata identified by name.

See: https://rokka.io/documentation/references/image-metadata.html

func (*Client) DownloadSourceImage

func (c *Client) DownloadSourceImage(org, hash string) (DownloadSourceImageResponse, error)

DownloadSourceImage allows to download the source image once uploaded.

See: https://rokka.io/documentation/references/source-images.html

func (Client) GetConfig

func (c Client) GetConfig() Config

GetConfig can be used for reading out the configuration of client.

func (*Client) GetOperations

func (c *Client) GetOperations() (OperationsResponse, error)

GetOperations returns the available stack options definition.

See: https://rokka.io/documentation/references/operations.html

func (*Client) GetOrganization

func (c *Client) GetOrganization(name string) (OrganizationResponse, error)

GetOrganization returns information about the requested organization if the passed API key is allowed to access it.

See: https://rokka.io/documentation/references/organizations.html#read-data-of-one-organization

func (*Client) GetSourceImage

func (c *Client) GetSourceImage(org, hash string) (GetSourceImageResponse, error)

GetSourceImage returns the metadata of a single source image identified by its hash.

See: https://rokka.io/documentation/references/source-images.html#retrieve-data-about-a-source-image

func (*Client) GetStackOptions

func (c *Client) GetStackOptions() (StackOptionsResponse, error)

GetStackOptions returns the available stack options definition.

func (*Client) GetStats

func (c *Client) GetStats(org string, options GetStatsOptions) (StatsResponse, error)

GetStats retrieves statistics for an organization.

See: https://rokka.io/documentation/references/stats.html

func (*Client) GetURL

func (c *Client) GetURL(organization, hash, format string, ops []Operation) (string, error)

GetURL generates an URL for the given organization, image hash, and format based on the list of operations given to it. If the operation slice is empty it generates a default noop operation. The URL returned has the format: `https://{imageHost for org}/dynamic/{stacks-applied-with-options}/{hash}.{format}`.

func (*Client) GetURLForStack

func (c *Client) GetURLForStack(organization, hash, format, stack string, ops []Operation) (string, error)

GetURLForStack generates an URL for the given organization, stack name, image hash, and format. The operations are added on top of the stack. If the operation slice is empty it generates a default noop operation. The URL returned has the format: `https://{imageHost for org}/{stack}/{stacks-applied-with-options}/{hash}.{format}`.

func (*Client) GetUserID

func (c *Client) GetUserID() (CreateUserIDResponse, error)

GetUserID returns the user uuid of the logged in user

See: https://rokka.io/documentation/references/users-and-memberships.html#get-the-current-user_id

func (*Client) ListMembership

func (c *Client) ListMembership(org string) (ListMembershipsResponse, error)

ListMembership lists all membership of an organisation

See: https://rokka.io/documentation/references/users-and-memberships.html#list-memberships

func (*Client) ListMembershipForUUID

func (c *Client) ListMembershipForUUID(org string, uuid string) (Membership, error)

ListMembershipForUUID list the membership of an user and organisation

See: https://rokka.io/documentation/references/users-and-memberships.html#list-memberships

func (*Client) ListSourceImages

func (c *Client) ListSourceImages(org string, options ListSourceImagesOptions) (ListSourceImagesResponse, error)

ListSourceImages gets a paginated list of source images.

See: https://rokka.io/documentation/references/searching-images.html

func (*Client) ListStacks

func (c *Client) ListStacks(org string) (ListStacksResponse, error)

ListStacks returns the stacks for the specified organization.

See: https://rokka.io/documentation/references/stacks.html#retrieve-a-stack

func (*Client) NewRequest

func (c *Client) NewRequest(method, path string, body io.Reader, query url.Values) (*http.Request, error)

NewRequest constructs a new http.Request used for executing using Call.

func (*Client) RestoreSourceImage

func (c *Client) RestoreSourceImage(org, hash string) error

RestoreSourceImage restores a source image by hash.

See: https://rokka.io/documentation/references/source-images.html

func (*Client) SetUserMetadata

func (c *Client) SetUserMetadata(org, hash string, data io.Reader) error

SetUserMetadata updates a source image by adding arbitrary metadata. If there were previous user metadata set on this source image, they'll get overwritten.

See: https://rokka.io/documentation/references/image-metadata.html

func (*Client) UpdateUserMetadata

func (c *Client) UpdateUserMetadata(org, hash string, data io.Reader) error

UpdateUserMetadata updates a source image by adding arbitrary metadata. Previous values get merged with the new values.

See: https://rokka.io/documentation/references/image-metadata.html

func (*Client) UpdateUserMetadataByName

func (c *Client) UpdateUserMetadataByName(org, hash, name string, data io.Reader) error

UpdateUserMetadataByName updates a source image by setting user metadata identified by name.

See: https://rokka.io/documentation/references/image-metadata.html

func (*Client) ValidAPIKey

func (c *Client) ValidAPIKey() (bool, error)

ValidAPIKey can be used to check if the API key is valid. It will execute a request to `/` which is an undocumented API. This function only returns true if there has been no error and the status code is < 400.

type CompositionOperation

type CompositionOperation struct {
	Anchor           *string `json:"anchor,omitempty"`
	Enabled          *bool   `json:"enabled,omitempty"`
	Height           *int    `json:"height,omitempty"`
	Mode             *string `json:"mode,omitempty"`
	ResizeMode       *string `json:"resize_mode,omitempty"`
	ResizeToPrimary  *bool   `json:"resize_to_primary,omitempty"`
	SecondaryColor   *string `json:"secondary_color,omitempty"`
	SecondaryImage   *string `json:"secondary_image,omitempty"`
	SecondaryOpacity *int    `json:"secondary_opacity,omitempty"`
	Width            *int    `json:"width,omitempty"`
}

CompositionOperation is an auto-generated Operation as specified by the rokka API.

See: https://rokka.io/documentation/references/operations.html

func (CompositionOperation) Name

func (o CompositionOperation) Name() string

Name implements rokka.Operation.Name

func (CompositionOperation) Validate

func (o CompositionOperation) Validate() (bool, error)

Validate implements rokka.Operation.Validate.

type Config

type Config struct {
	APIAddress         string
	APIVersion         string
	APIKey             string
	ImageHost          string
	Verbose            bool
	HTTPClient         HTTPRequester
	RetryingHTTPClient HTTPRequester
}

Config contains configuration for Client.

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig is used when calling NewClient with not all config options set.

type CreateCopySourceImagesResponse

type CreateCopySourceImagesResponse struct {
	Created  []string `json:"created"`
	Existing []string `json:"existing"`
	Notfound []string `json:"notfound"`
}

CreateCopySourceImagesResponse is returned when copying multiple images

type CreateSourceImageResponse

type CreateSourceImageResponse struct {
	Total int                      `json:"total"`
	Items []GetSourceImageResponse `json:"items"`
}

CreateSourceImageResponse is returned when creating an image.

type CreateStackRequest

type CreateStackRequest struct {
	Operations  Operations   `json:"operations"`
	Options     StackOptions `json:"options,omitempty"`
	Expressions []Expression `json:"expressions,omitempty"`
}

CreateStackRequest specifies the stack to create.

type CreateUserIDResponse

type CreateUserIDResponse struct {
	ID string `json:"user_id"`
}

CreateUserIDResponse contains information about the user id of a user

type CreateUserResponse

type CreateUserResponse struct {
	ID     string `json:"id"`
	Email  string `json:"email"`
	APIKey string `json:"api_key"`
}

CreateUserResponse contains information about a newly created organization and user

type CropOperation

type CropOperation struct {
	Anchor   *string  `json:"anchor,omitempty"`
	Area     *string  `json:"area,omitempty"`
	Enabled  *bool    `json:"enabled,omitempty"`
	Fallback *string  `json:"fallback,omitempty"`
	Height   *int     `json:"height,omitempty"`
	Mode     *string  `json:"mode,omitempty"`
	Scale    *float64 `json:"scale,omitempty"`
	Width    *int     `json:"width,omitempty"`
}

CropOperation is an auto-generated Operation as specified by the rokka API. Calling .Validate() will return false if required properties are missing.

See: https://rokka.io/documentation/references/operations.html

func (CropOperation) Name

func (o CropOperation) Name() string

Name implements rokka.Operation.Name

func (CropOperation) Validate

func (o CropOperation) Validate() (bool, error)

Validate implements rokka.Operation.Validate.

type DownloadSourceImageResponse

type DownloadSourceImageResponse struct {
	Data     io.ReadCloser
	FileName string
}

DownloadSourceImageResponse contains the original data as a byte slice and the filename.

type DropshadowOperation

type DropshadowOperation struct {
	BlurRadius *float64 `json:"blur_radius,omitempty"`
	Color      *string  `json:"color,omitempty"`
	Enabled    *bool    `json:"enabled,omitempty"`
	Horizontal *int     `json:"horizontal,omitempty"`
	Opacity    *int     `json:"opacity,omitempty"`
	Sigma      *float64 `json:"sigma,omitempty"`
	Vertical   *int     `json:"vertical,omitempty"`
}

DropshadowOperation is an auto-generated Operation as specified by the rokka API.

See: https://rokka.io/documentation/references/operations.html

func (DropshadowOperation) Name

func (o DropshadowOperation) Name() string

Name implements rokka.Operation.Name

func (DropshadowOperation) Validate

func (o DropshadowOperation) Validate() (bool, error)

Validate implements rokka.Operation.Validate.

type DynamicMetadataOptions

type DynamicMetadataOptions struct {
	DeletePrevious bool `url:"deletePrevious,omitempty"`
}

DynamicMetadataOptions defines the accepted options for adding dynamic metadata to an image.

type DynamicMetadataResponse

type DynamicMetadataResponse struct {
	Location string
}

DynamicMetadataResponse contains the location of the updated image.

type ErrMaxRetriesReached

type ErrMaxRetriesReached struct {
	LastError error
}

ErrMaxRetriesReached is returned if after maxRetries number of retries the request still fails.

func (ErrMaxRetriesReached) Error

func (e ErrMaxRetriesReached) Error() string

type Expression

type Expression struct {
	Expression string                 `json:"expression"`
	Overrides  map[string]interface{} `json:"overrides"`
}

Expression allows to override certain behaviour of a stack based on e.g. DPR size of the requesting client.

type GetSourceImageResponse

type GetSourceImageResponse struct {
	Hash            string                 `json:"hash"`
	ShortHash       string                 `json:"short_hash"`
	BinaryHash      string                 `json:"binary_hash"`
	Created         time.Time              `json:"created"`
	Name            string                 `json:"name"`
	MimeType        string                 `json:"mimetype"`
	Format          string                 `json:"format"`
	Size            int                    `json:"size"`
	Width           int                    `json:"width"`
	Height          int                    `json:"height"`
	Organization    string                 `json:"organization"`
	Link            string                 `json:"link"`
	UserMetadata    map[string]interface{} `json:"user_metadata,omitempty"`
	DynamicMetadata map[string]interface{} `json:"dynamic_metadata,omitempty"`
}

GetSourceImageResponse is an object identifying an image.

type GetStatsOptions

type GetStatsOptions struct {
	From string `url:"from,omitempty"`
	To   string `url:"to,omitempty"`
}

GetStatsOptions defines the accepted querystring params for GetStats. Giving an empty struct will result in no querystring params being sent to rokka.

type GlitchOperation

type GlitchOperation struct {
	Amount  *int    `json:"amount,omitempty"`
	Enabled *bool   `json:"enabled,omitempty"`
	Random  *string `json:"random,omitempty"`
}

GlitchOperation is an auto-generated Operation as specified by the rokka API.

See: https://rokka.io/documentation/references/operations.html

func (GlitchOperation) Name

func (o GlitchOperation) Name() string

Name implements rokka.Operation.Name

func (GlitchOperation) Validate

func (o GlitchOperation) Validate() (bool, error)

Validate implements rokka.Operation.Validate.

type GrayscaleOperation

type GrayscaleOperation struct {
	Enabled *bool `json:"enabled,omitempty"`
}

GrayscaleOperation is an auto-generated Operation as specified by the rokka API.

See: https://rokka.io/documentation/references/operations.html

func (GrayscaleOperation) Name

func (o GrayscaleOperation) Name() string

Name implements rokka.Operation.Name

func (GrayscaleOperation) Validate

func (o GrayscaleOperation) Validate() (bool, error)

Validate implements rokka.Operation.Validate.

type HTTPRequester

type HTTPRequester interface {
	Do(req *http.Request) (*http.Response, error)
}

HTTPRequester is an interface defining the Do function. http.Client is automatically implementing that interface.

type ListMembershipsResponse

type ListMembershipsResponse struct {
	Items []Membership `json:"items"`
}

ListMembershipsResponse is a collection of multiple membership objects in Items.

type ListSourceImagesOptions

type ListSourceImagesOptions struct {
	Limit      int    `url:"limit,omitempty"`
	Offset     string `url:"offset,omitempty"`
	Hash       string `url:"hash,omitempty"`
	BinaryHash string `url:"binaryhash,omitempty"`
	// Size can be an int or a range. See: https://github.com/rokka-io/rokka-go/issues/32
	Size   string `url:"size,omitempty"`
	Format string `url:"format,omitempty"`
	// Width can be an int or a range. See: https://github.com/rokka-io/rokka-go/issues/32
	Width string `url:"width,omitempty"`
	// Height can be an int or a range. See: https://github.com/rokka-io/rokka-go/issues/32
	Height string `url:"height,omitempty"`
	// Created needs to be always passed as a range.
	Created string `url:"created,omitempty"`
	// Sort by a specific field
	Sort string `url:"sort,omitempty"`
}

ListSourceImagesOptions defines the accepted query string params for GetStats. Giving an empty struct will result in no query string params being sent to rokka.

See: https://rokka.io/documentation/references/searching-images.html#range-filtering

type ListSourceImagesResponse

type ListSourceImagesResponse struct {
	Total  int                      `json:"total"`
	Items  []GetSourceImageResponse `json:"items"`
	Cursor string                   `json:"cursor"`
	Links  struct {
		Prev *struct {
			Href string `json:"href,omitempty"`
		} `json:"prev,omitempty"`
		Next *struct {
			Href string `json:"href,omitempty"`
		} `json:"next,omitempty"`
	} `json:"links,omitempty"`
}

ListSourceImagesResponse contains a list of source images alongside a total and pagination links.

type ListStacksResponse

type ListStacksResponse struct {
	Items []Stack `json:"items"`
}

ListStacksResponse contains a list of stacks each containing a list of operations.

type Membership

type Membership struct {
	OrganizationID string   `json:"organization_id"`
	Email          string   `json:"email"`
	UserID         string   `json:"user_id"`
	Roles          []string `json:"roles"`
	APIKey         string   `json:"api_key"`
}

Membership holds all the info for a membership.

type MembershipRole

type MembershipRole string

MembershipRole is a simple alias to string for the defined constants.

const (
	RoleRead   MembershipRole = "read"
	RoleWrite  MembershipRole = "write"
	RoleAdmin  MembershipRole = "admin"
	RoleUpload MembershipRole = "upload"
)

RoleRead, RoleWrite, RoleAdmin and RoleUpload are membership roles.

type ModulateOperation

type ModulateOperation struct {
	Brightness *int  `json:"brightness,omitempty"`
	Enabled    *bool `json:"enabled,omitempty"`
	Hue        *int  `json:"hue,omitempty"`
	Saturation *int  `json:"saturation,omitempty"`
}

ModulateOperation is an auto-generated Operation as specified by the rokka API.

See: https://rokka.io/documentation/references/operations.html

func (ModulateOperation) Name

func (o ModulateOperation) Name() string

Name implements rokka.Operation.Name

func (ModulateOperation) Validate

func (o ModulateOperation) Validate() (bool, error)

Validate implements rokka.Operation.Validate.

type NoopOperation

type NoopOperation struct {
	Enabled *bool `json:"enabled,omitempty"`
}

NoopOperation is an auto-generated Operation as specified by the rokka API.

See: https://rokka.io/documentation/references/operations.html

func (NoopOperation) Name

func (o NoopOperation) Name() string

Name implements rokka.Operation.Name

func (NoopOperation) Validate

func (o NoopOperation) Validate() (bool, error)

Validate implements rokka.Operation.Validate.

type Operation

type Operation interface {
	// Name returns the operation's name known by the API.
	Name() string
	// Validate checks if required properties are set.
	// Otherwise it returns false with an error indicating the missing property.
	Validate() (bool, error)
	// contains filtered or unexported methods
}

Operation is an interface all operation structs implement.

func NewOperationByName

func NewOperationByName(name string) (Operation, error)

NewOperationByName creates a struct of the respective type based on the name given.

type Operations

type Operations []Operation

Operations is a slice of Operation implementing json.Unmarshaler and json.Marshaler in order to create the correct operation types for JSON.

func (Operations) MarshalJSON

func (o Operations) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler

func (*Operations) UnmarshalJSON

func (o *Operations) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler.

type OperationsResponse

type OperationsResponse map[string]map[string]interface{}

OperationsResponse contains the available stack options.

type OrganizationResponse

type OrganizationResponse struct {
	ID                 string    `json:"id"`
	DisplayName        string    `json:"display_name"`
	Name               string    `json:"name"`
	BillingEmail       string    `json:"billing_email"`
	Created            time.Time `json:"created"`
	MasterOrganization string    `json:"master_organization"`
	Limit              *struct {
		SpaceInBytes   int `json:"space_in_bytes,omitempty"`
		TrafficInBytes int `json:"traffic_in_bytes,omitempty"`
	} `json:"limit,omitempty"`
}

OrganizationResponse contains the information about an organization.

type PrimitiveOperation

type PrimitiveOperation struct {
	Count   *int  `json:"count,omitempty"`
	Enabled *bool `json:"enabled,omitempty"`
	Mode    *int  `json:"mode,omitempty"`
}

PrimitiveOperation is an auto-generated Operation as specified by the rokka API.

See: https://rokka.io/documentation/references/operations.html

func (PrimitiveOperation) Name

func (o PrimitiveOperation) Name() string

Name implements rokka.Operation.Name

func (PrimitiveOperation) Validate

func (o PrimitiveOperation) Validate() (bool, error)

Validate implements rokka.Operation.Validate.

type ResizeOperation

type ResizeOperation struct {
	Enabled    *bool   `json:"enabled,omitempty"`
	Height     *int    `json:"height,omitempty"`
	Mode       *string `json:"mode,omitempty"`
	Upscale    *bool   `json:"upscale,omitempty"`
	UpscaleDpr *bool   `json:"upscale_dpr,omitempty"`
	Width      *int    `json:"width,omitempty"`
}

ResizeOperation is an auto-generated Operation as specified by the rokka API. Calling .Validate() will return false if required properties are missing.

See: https://rokka.io/documentation/references/operations.html

func (ResizeOperation) Name

func (o ResizeOperation) Name() string

Name implements rokka.Operation.Name

func (ResizeOperation) Validate

func (o ResizeOperation) Validate() (bool, error)

Validate implements rokka.Operation.Validate.

type RetryingHTTPClient

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

RetryingHTTPClient implements HTTPRequester and wraps another HTTPRequester.

func NewRetryingHTTPClient

func NewRetryingHTTPClient(c HTTPRequester, maxRetries int, maxDelay int) *RetryingHTTPClient

NewRetryingHTTPClient wraps an HTTPRequester in order to do automatic retries.

These are done in the following cases:

  • a HTTP, Network or Transport error occurred
  • a status code of 429 (too many requests), 502 (bad gateway), 503 (service unavailable), or 504 (gateway timeout) has been received.

func (*RetryingHTTPClient) Do

func (hc *RetryingHTTPClient) Do(req *http.Request) (*http.Response, error)

Do executes an HTTP request and retries in case the response status code is one 429, 502, 503, 504 or if error is set.

type RotateOperation

type RotateOperation struct {
	Angle             *float64 `json:"angle,omitempty"`
	BackgroundColor   *string  `json:"background_color,omitempty"`
	BackgroundOpacity *float64 `json:"background_opacity,omitempty"`
	Enabled           *bool    `json:"enabled,omitempty"`
}

RotateOperation is an auto-generated Operation as specified by the rokka API. Calling .Validate() will return false if required properties are missing.

See: https://rokka.io/documentation/references/operations.html

func (RotateOperation) Name

func (o RotateOperation) Name() string

Name implements rokka.Operation.Name

func (RotateOperation) Validate

func (o RotateOperation) Validate() (bool, error)

Validate implements rokka.Operation.Validate.

type SepiaOperation

type SepiaOperation struct {
	Enabled *bool `json:"enabled,omitempty"`
}

SepiaOperation is an auto-generated Operation as specified by the rokka API.

See: https://rokka.io/documentation/references/operations.html

func (SepiaOperation) Name

func (o SepiaOperation) Name() string

Name implements rokka.Operation.Name

func (SepiaOperation) Validate

func (o SepiaOperation) Validate() (bool, error)

Validate implements rokka.Operation.Validate.

type Stack

type Stack struct {
	Organization     string       `json:"organization"`
	Name             string       `json:"name"`
	Created          time.Time    `json:"created"`
	StackOptions     StackOptions `json:"stack_options"`
	StackOperations  Operations   `json:"stack_operations"`
	StackExpressions []Expression `json:"stack_expressions"`
}

Stack specifies the data of a stack.

type StackOptions

type StackOptions map[string]interface{}

StackOptions allows to specify certain settings for a stack. Examples are the compression levels depending on the image format.

type StackOptionsResponse

type StackOptionsResponse struct {
	Properties map[string]struct {
		Type      interface{} `json:"type"`
		MinLength *int        `json:"minLength,omitempty"`
		Values    []string    `json:"values,omitempty"`
		Default   interface{} `json:"default,omitempty"`
		Minimum   *int        `json:"minimum,omitempty"`
		Maximum   *int        `json:"maximum,omitempty"`
	} `json:"properties"`
}

StackOptionsResponse contains the available stack options.

type StatsResponse

type StatsResponse struct {
	SpaceInBytes    []statsResponseValue `json:"space_in_bytes"`
	NumberOfFiles   []statsResponseValue `json:"number_of_files"`
	BytesDownloaded []statsResponseValue `json:"bytes_downloaded"`
}

StatsResponse contains time based statistics for an organization.

type StatusCodeError

type StatusCodeError struct {
	Code     int
	APIError *APIError
	Body     []byte
}

StatusCodeError satifies the Error interface and is returned when a response contains a status code >= 400.

func (StatusCodeError) Error

func (e StatusCodeError) Error() string

Error creates an error string.

type TrimOperation

type TrimOperation struct {
	Enabled *bool    `json:"enabled,omitempty"`
	Fuzzy   *float64 `json:"fuzzy,omitempty"`
}

TrimOperation is an auto-generated Operation as specified by the rokka API.

See: https://rokka.io/documentation/references/operations.html

func (TrimOperation) Name

func (o TrimOperation) Name() string

Name implements rokka.Operation.Name

func (TrimOperation) Validate

func (o TrimOperation) Validate() (bool, error)

Validate implements rokka.Operation.Validate.

Notes

Bugs

  • We continue here when such an error is reached because rokka sometimes (legacy reasons)

    has options on an operation which are not of the correct type. Should we write something to stdout? also not nice though..
    

Jump to

Keyboard shortcuts

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