gophercloud: github.com/rackspace/gophercloud/openstack/cdn/v1/services Index | Files

package services

import "github.com/rackspace/gophercloud/openstack/cdn/v1/services"

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

Package Files

doc.go errors.go requests.go results.go urls.go

Variables

var (
    // PathDomains indicates that an update operation is to be performed on a Domain.
    PathDomains = Path{baseElement: "domains"}

    // PathOrigins indicates that an update operation is to be performed on an Origin.
    PathOrigins = Path{baseElement: "origins"}

    // PathCaching indicates that an update operation is to be performed on a CacheRule.
    PathCaching = Path{baseElement: "caching"}
)

func ExtractServices Uses

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

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

func List Uses

func List(c *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager

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.

type Append Uses

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 Uses

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

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

type CacheRule Uses

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

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

type CacheRuleList Uses

type CacheRuleList []CacheRule

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

type CreateOpts Uses

type CreateOpts struct {
    // REQUIRED. Specifies the name of the service. The minimum length for name is
    // 3. The maximum length is 256.
    Name string
    // REQUIRED. Specifies a list of domains used by users to access their website.
    Domains []Domain
    // REQUIRED. Specifies a list of origin domains or IP addresses where the
    // original assets are stored.
    Origins []Origin
    // REQUIRED. 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
    // OPTIONAL. Specifies the TTL rules for the assets under this service. Supports wildcards for fine-grained control.
    Caching []CacheRule
    // OPTIONAL. Specifies the restrictions that define who can access assets (content from the CDN cache).
    Restrictions []Restriction
}

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

func (CreateOpts) ToCDNServiceCreateMap Uses

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

ToCDNServiceCreateMap casts a CreateOpts struct to a map.

type CreateOptsBuilder Uses

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 Uses

type CreateResult struct {
    gophercloud.Result
}

CreateResult represents the result of a Create operation.

func Create Uses

func Create(c *gophercloud.ServiceClient, opts CreateOptsBuilder) CreateResult

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

func (CreateResult) Extract Uses

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

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

type DeleteResult Uses

type DeleteResult struct {
    gophercloud.ErrResult
}

DeleteResult represents the result of a Delete operation.

func Delete Uses

func Delete(c *gophercloud.ServiceClient, idOrURL string) 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 Uses

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 `mapstructure:"domain" json:"domain"`
    // Specifies the protocol used to access the assets on this domain. Only "http"
    // or "https" are currently allowed. The default is "http".
    Protocol string `mapstructure:"protocol" json:"protocol,omitempty"`
}

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

type DomainList Uses

type DomainList []Domain

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

type Error Uses

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

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

type GetResult Uses

type GetResult struct {
    gophercloud.Result
}

GetResult represents the result of a get operation.

func Get Uses

func Get(c *gophercloud.ServiceClient, idOrURL string) 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 Uses

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

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

type Insertion Uses

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 Uses

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

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

type ListOpts Uses

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 Uses

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

ToCDNServiceListQuery formats a ListOpts into a query string.

type ListOptsBuilder Uses

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

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

type NameReplacement Uses

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 Uses

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

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

type Origin Uses

type Origin struct {
    // Specifies the URL or IP address to pull origin content from.
    Origin string `mapstructure:"origin" json:"origin"`
    // Specifies the port used to access the origin. The default is port 80.
    Port int `mapstructure:"port" json:"port,omitempty"`
    // Specifies whether or not to use HTTPS to access the origin. The default
    // is false.
    SSL bool `mapstructure:"ssl" 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 `mapstructure:"rules" json:"rules,omitempty"`
}

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

type OriginList Uses

type OriginList []Origin

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

type OriginRule Uses

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

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

type Patch Uses

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 Uses

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 Uses

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 Uses

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

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

type Replacement Uses

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 Uses

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

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

type Restriction Uses

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

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

type RestrictionRule Uses

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

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

type Service Uses

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 `mapstructure:"id"`
    // Specifies the name of the service.
    Name string `mapstructure:"name"`
    // Specifies a list of domains used by users to access their website.
    Domains []Domain `mapstructure:"domains"`
    // Specifies a list of origin domains or IP addresses where the original assets are stored.
    Origins []Origin `mapstructure:"origins"`
    // Specifies the TTL rules for the assets under this service. Supports wildcards for fine grained control.
    Caching []CacheRule `mapstructure:"caching"`
    // Specifies the restrictions that define who can access assets (content from the CDN cache).
    Restrictions []Restriction `mapstructure:"restrictions" json:"restrictions,omitempty"`
    // Specifies the CDN provider flavor ID to use. For a list of flavors, see the operation to list the available flavors.
    FlavorID string `mapstructure:"flavor_id"`
    // Specifies the current status of the service.
    Status string `mapstructure:"status"`
    // Specifies the list of errors that occurred during the previous service action.
    Errors []Error `mapstructure:"errors"`
    // Specifies the self-navigating JSON document paths.
    Links []gophercloud.Link `mapstructure:"links"`
}

Service represents a CDN service resource.

type ServicePage Uses

type ServicePage struct {
    pagination.MarkerPageBase
}

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

func (ServicePage) IsEmpty Uses

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

IsEmpty returns true if a ListResult contains no services.

func (ServicePage) LastMarker Uses

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

LastMarker returns the last service in a ListResult.

type TTLRule Uses

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

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

type UpdateOpts Uses

type UpdateOpts []Patch

type UpdateResult Uses

type UpdateResult struct {
    gophercloud.Result
}

UpdateResult represents the result of a Update operation.

func Update Uses

func Update(c *gophercloud.ServiceClient, idOrURL string, opts UpdateOpts) 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 Uses

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

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

Package services imports 5 packages (graph) and is imported by 1 packages. Updated 2016-07-23. Refresh now. Tools for package owners.