services

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2019 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package services provides information and interaction with the services API resource in the OpenStack CDN service. This API resource allows for listing, creating, updating, retrieving, and deleting services.

A service represents an application that has its content cached to the edge nodes.

Index

Constants

This section is empty.

Variables

View Source
var (
	// PathDomains indicates that an update operation is to be performed on a Domain.
	PathDomains = Path{/* contains filtered or unexported fields */}

	// PathOrigins indicates that an update operation is to be performed on an Origin.
	PathOrigins = Path{/* contains filtered or unexported fields */}

	// PathCaching indicates that an update operation is to be performed on a CacheRule.
	PathCaching = Path{/* contains filtered or unexported fields */}
)

Functions

func List

List returns a Pager which allows you to iterate over a collection of CDN services. It accepts a ListOpts struct, which allows for pagination via marker and limit.

Types

type Append

type Append struct {
	Value value
}

Append is a Patch that requests the addition of a value (Domain, Origin, or CacheRule) to a Service at the end of its respective collection. Use an Insertion instead to insert the value at a fixed index within the collection. Pass this to the Update function as part of its Patch slice.

func (Append) ToCDNServiceUpdateMap

func (a Append) ToCDNServiceUpdateMap() map[string]interface{}

ToCDNServiceUpdateMap converts an Append into a request body fragment suitable for the Update call.

type CacheRule

type CacheRule struct {
	// Specifies the name of this caching rule. Note: 'default' is a reserved name used for the default TTL setting.
	Name string `json:"name" required:"true"`
	// Specifies the TTL to apply.
	TTL int `json:"ttl,omitempty"`
	// Specifies a collection of rules that determine if this TTL should be applied to an asset.
	Rules []TTLRule `json:"rules,omitempty"`
}

CacheRule specifies the TTL rules for the assets under this service.

type CacheRuleList

type CacheRuleList []CacheRule

CacheRuleList provides a useful way to perform bulk operations in a single Patch.

type CreateOpts

type CreateOpts struct {
	// Specifies the name of the service. The minimum length for name is
	// 3. The maximum length is 256.
	Name string `json:"name" required:"true"`
	// Specifies a list of domains used by users to access their website.
	Domains []Domain `json:"domains" required:"true"`
	// Specifies a list of origin domains or IP addresses where the
	// original assets are stored.
	Origins []Origin `json:"origins" required:"true"`
	// Specifies the CDN provider flavor ID to use. For a list of
	// flavors, see the operation to list the available flavors. The minimum
	// length for flavor_id is 1. The maximum length is 256.
	FlavorID string `json:"flavor_id" required:"true"`
	// Specifies the TTL rules for the assets under this service. Supports wildcards for fine-grained control.
	Caching []CacheRule `json:"caching,omitempty"`
	// Specifies the restrictions that define who can access assets (content from the CDN cache).
	Restrictions []Restriction `json:"restrictions,omitempty"`
}

CreateOpts is the common options struct used in this package's Create operation.

func (CreateOpts) ToCDNServiceCreateMap

func (opts CreateOpts) ToCDNServiceCreateMap() (map[string]interface{}, error)

ToCDNServiceCreateMap casts a CreateOpts struct to a map.

type CreateOptsBuilder

type CreateOptsBuilder interface {
	ToCDNServiceCreateMap() (map[string]interface{}, error)
}

CreateOptsBuilder is the interface options structs have to satisfy in order to be used in the main Create operation in this package. Since many extensions decorate or modify the common logic, it is useful for them to satisfy a basic interface in order for them to be used.

type CreateResult

type CreateResult struct {
	gophercloud.Result
}

CreateResult represents the result of a Create operation.

func Create

Create accepts a CreateOpts struct and creates a new CDN service using the values provided.

func (CreateResult) Extract

func (r CreateResult) Extract() (string, error)

Extract is a method that extracts the location of a newly created service.

type DeleteResult

type DeleteResult struct {
	gophercloud.ErrResult
}

DeleteResult represents the result of a Delete operation.

func Delete

func Delete(c *gophercloud.ServiceClient, idOrURL string) (r DeleteResult)

Delete accepts a service's ID or its URL and deletes the CDN service associated with it. For example, both "96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0" and "https://global.cdn.api.rackspacecloud.com/v1.0/services/96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0" are valid options for idOrURL.

type Domain

type Domain struct {
	// Specifies the domain used to access the assets on their website, for which
	// a CNAME is given to the CDN provider.
	Domain string `json:"domain" required:"true"`
	// Specifies the protocol used to access the assets on this domain. Only "http"
	// or "https" are currently allowed. The default is "http".
	Protocol string `json:"protocol,omitempty"`
}

Domain represents a domain used by users to access their website.

type DomainList

type DomainList []Domain

DomainList provides a useful way to perform bulk operations in a single Patch.

type Error

type Error struct {
	// Specifies an error message detailing why there is an error.
	Message string `json:"message"`
}

Error specifies an error that occurred during the previous service action.

type GetResult

type GetResult struct {
	gophercloud.Result
}

GetResult represents the result of a get operation.

func Get

func Get(c *gophercloud.ServiceClient, idOrURL string) (r GetResult)

Get retrieves a specific service based on its URL or its unique ID. For example, both "96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0" and "https://global.cdn.api.rackspacecloud.com/v1.0/services/96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0" are valid options for idOrURL.

func (GetResult) Extract

func (r GetResult) Extract() (*Service, error)

Extract is a function that extracts a service from a GetResult.

type Insertion

type Insertion struct {
	Index int64
	Value value
}

Insertion is a Patch that requests the addition of a value (Domain, Origin, or CacheRule) to a Service at a fixed index. Use an Append instead to append the new value to the end of its collection. Pass it to the Update function as part of the Patch slice.

func (Insertion) ToCDNServiceUpdateMap

func (opts Insertion) ToCDNServiceUpdateMap() map[string]interface{}

ToCDNServiceUpdateMap converts an Insertion into a request body fragment suitable for the Update call.

type ListOpts

type ListOpts struct {
	Marker string `q:"marker"`
	Limit  int    `q:"limit"`
}

ListOpts allows the filtering and sorting of paginated collections through the API. Marker and Limit are used for pagination.

func (ListOpts) ToCDNServiceListQuery

func (opts ListOpts) ToCDNServiceListQuery() (string, error)

ToCDNServiceListQuery formats a ListOpts into a query string.

type ListOptsBuilder

type ListOptsBuilder interface {
	ToCDNServiceListQuery() (string, error)
}

ListOptsBuilder allows extensions to add additional parameters to the List request.

type NameReplacement

type NameReplacement struct {
	NewName string
}

NameReplacement specifically updates the Service name. Pass it to the Update function as part of the Patch slice.

func (NameReplacement) ToCDNServiceUpdateMap

func (r NameReplacement) ToCDNServiceUpdateMap() map[string]interface{}

ToCDNServiceUpdateMap converts a NameReplacement into a request body fragment suitable for the Update call.

type Origin

type Origin struct {
	// Specifies the URL or IP address to pull origin content from.
	Origin string `json:"origin" required:"true"`
	// Specifies the port used to access the origin. The default is port 80.
	Port int `json:"port,omitempty"`
	// Specifies whether or not to use HTTPS to access the origin. The default
	// is false.
	SSL bool `json:"ssl"`
	// Specifies a collection of rules that define the conditions when this origin
	// should be accessed. If there is more than one origin, the rules parameter is required.
	Rules []OriginRule `json:"rules,omitempty"`
}

Origin specifies a list of origin domains or IP addresses where the original assets are stored.

type OriginList

type OriginList []Origin

OriginList provides a useful way to perform bulk operations in a single Patch.

type OriginRule

type OriginRule struct {
	// Specifies the name of this rule.
	Name string `json:"name" required:"true"`
	// Specifies the request URL this rule should match for this origin to be used. Regex is supported.
	RequestURL string `json:"request_url" required:"true"`
}

OriginRule represents a rule that defines when an origin should be accessed.

type Patch

type Patch interface {
	ToCDNServiceUpdateMap() map[string]interface{}
}

Patch represents a single update to an existing Service. Multiple updates to a service can be submitted at the same time.

type Path

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

Path is a JSON pointer location that indicates which service parameter is being added, replaced, or removed.

type Removal

type Removal struct {
	Path  Path
	Index int64
	All   bool
}

Removal is a Patch that requests the removal of a service parameter (Domain, Origin, or CacheRule) by index. Pass it to the Update function as part of the Patch slice.

func (Removal) ToCDNServiceUpdateMap

func (opts Removal) ToCDNServiceUpdateMap() map[string]interface{}

ToCDNServiceUpdateMap converts a Removal into a request body fragment suitable for the Update call.

type Replacement

type Replacement struct {
	Value value
	Index int64
}

Replacement is a Patch that alters a specific service parameter (Domain, Origin, or CacheRule) in-place by index. Pass it to the Update function as part of the Patch slice.

func (Replacement) ToCDNServiceUpdateMap

func (r Replacement) ToCDNServiceUpdateMap() map[string]interface{}

ToCDNServiceUpdateMap converts a Replacement into a request body fragment suitable for the Update call.

type Restriction

type Restriction struct {
	// Specifies the name of this restriction.
	Name string `json:"name" required:"true"`
	// Specifies a collection of rules that determine if this TTL should be applied to an asset.
	Rules []RestrictionRule `json:"rules,omitempty"`
}

Restriction specifies a restriction that defines who can access assets (content from the CDN cache).

type RestrictionRule

type RestrictionRule struct {
	// Specifies the name of this rule.
	Name string `json:"name" required:"true"`
	// Specifies the http host that requests must come from.
	Referrer string `json:"referrer,omitempty"`
}

RestrictionRule specifies a rule that determines if this restriction should be applied to an asset.

type Service

type Service struct {
	// Specifies the service ID that represents distributed content. The value is
	// a UUID, such as 96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0, that is generated by the server.
	ID string `json:"id"`
	// Specifies the name of the service.
	Name string `json:"name"`
	// Specifies a list of domains used by users to access their website.
	Domains []Domain `json:"domains"`
	// Specifies a list of origin domains or IP addresses where the original assets are stored.
	Origins []Origin `json:"origins"`
	// Specifies the TTL rules for the assets under this service. Supports wildcards for fine grained control.
	Caching []CacheRule `json:"caching"`
	// Specifies the restrictions that define who can access assets (content from the CDN cache).
	Restrictions []Restriction `json:"restrictions"`
	// Specifies the CDN provider flavor ID to use. For a list of flavors, see the operation to list the available flavors.
	FlavorID string `json:"flavor_id"`
	// Specifies the current status of the service.
	Status string `json:"status"`
	// Specifies the list of errors that occurred during the previous service action.
	Errors []Error `json:"errors"`
	// Specifies the self-navigating JSON document paths.
	Links []gophercloud.Link `json:"links"`
}

Service represents a CDN service resource.

func ExtractServices

func ExtractServices(r pagination.Page) ([]Service, error)

ExtractServices is a function that takes a ListResult and returns the services' information.

type ServicePage

type ServicePage struct {
	pagination.MarkerPageBase
}

ServicePage is the page returned by a pager when traversing over a collection of CDN services.

func (ServicePage) IsEmpty

func (r ServicePage) IsEmpty() (bool, error)

IsEmpty returns true if a ListResult contains no services.

func (ServicePage) LastMarker

func (r ServicePage) LastMarker() (string, error)

LastMarker returns the last service in a ListResult.

type TTLRule

type TTLRule struct {
	// Specifies the name of this rule.
	Name string `json:"name" required:"true"`
	// Specifies the request URL this rule should match for this TTL to be used. Regex is supported.
	RequestURL string `json:"request_url" required:"true"`
}

TTLRule specifies a rule that determines if a TTL should be applied to an asset.

type UpdateOpts

type UpdateOpts []Patch

UpdateOpts is a slice of Patches used to update a CDN service

type UpdateResult

type UpdateResult struct {
	gophercloud.Result
}

UpdateResult represents the result of a Update operation.

func Update

func Update(c *gophercloud.ServiceClient, idOrURL string, opts UpdateOpts) (r UpdateResult)

Update accepts a slice of Patch operations (Insertion, Append, Replacement or Removal) and updates an existing CDN service using the values provided. idOrURL can be either the service's URL or its ID. For example, both "96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0" and "https://global.cdn.api.rackspacecloud.com/v1.0/services/96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0" are valid options for idOrURL.

func (UpdateResult) Extract

func (r UpdateResult) Extract() (string, error)

Extract is a method that extracts the location of an updated service.

Directories

Path Synopsis
cdn_services_v1
cdn_services_v1

Jump to

Keyboard shortcuts

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