papi

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2017 License: Apache-2.0 Imports: 12 Imported by: 0

README

Akamai Property Manager API (PAPI)

A golang package which facilitates making requests to the Akamai OPEN Property Manager API.

Documentation

Overview

Package papi provides a simple wrapper for the Akamai Property Manager API

Index

Constants

View Source
const (
	// ActivationTypeActivate Activation.ActivationType value ACTIVATE
	ActivationTypeActivate ActivationValue = "ACTIVATE"
	// ActivationTypeDeactivate Activation.ActivationType value DEACTIVATE
	ActivationTypeDeactivate ActivationValue = "DEACTIVATE"

	// NetworkProduction Activation.Network value PRODUCTION
	NetworkProduction NetworkValue = "PRODUCTION"
	// NetworkStaging Activation.Network value STAGING
	NetworkStaging NetworkValue = "STAGING"

	// StatusActive Activation.Status value ACTIVE
	StatusActive StatusValue = "ACTIVE"
	// StatusInactive Activation.Status value INACTIVE
	StatusInactive StatusValue = "INACTIVE"
	// StatusPending Activation.Status value PENDING
	StatusPending StatusValue = "PENDING"
	// StatusZone1 Activation.Status value ZONE_1
	StatusZone1 StatusValue = "ZONE_1"
	// StatusZone2 Activation.Status value ZONE_2
	StatusZone2 StatusValue = "ZONE_2"
	// StatusZone3 Activation.Status value ZONE_3
	StatusZone3 StatusValue = "ZONE_3"
	// StatusAborted Activation.Status value ABORTED
	StatusAborted StatusValue = "ABORTED"
	// StatusFailed Activation.Status value FAILED
	StatusFailed StatusValue = "FAILED"
	// StatusDeactivated Activation.Status value DEACTIVATED
	StatusDeactivated StatusValue = "DEACTIVATED"
	// StatusPendingDeactivation Activation.Status value PENDING_DEACTIVATION
	StatusPendingDeactivation StatusValue = "PENDING_DEACTIVATION"
	// StatusNew Activation.Status value NEW
	StatusNew StatusValue = "NEW"
)
View Source
const (
	ErrInvalidPath = iota
	ErrCriteriaNotFound
	ErrBehaviorNotFound
	ErrRuleNotFound
	ErrInvalidRules
)

Error constants

Variables

View Source
var (
	Config edgegrid.Config
)
View Source
var (
	ErrorMap = map[int]error{
		ErrInvalidPath:      errors.New("Invalid Path"),
		ErrCriteriaNotFound: errors.New("Criteria not found"),
		ErrBehaviorNotFound: errors.New("Behavior not found"),
		ErrRuleNotFound:     errors.New("Rule not found"),
		ErrInvalidRules:     errors.New("Rule validation failed. See papi.Rules.Errors for details"),
	}
)

Functions

func Init

func Init(config edgegrid.Config)

Init sets the PAPI edgegrid Config

func PrintRules

func PrintRules(rules *Rules) error

PrintRules prints a reasonably easy to read tree of all rules and behaviors on a property

Types

type Activation

type Activation struct {
	client.Resource

	ActivationID        string                      `json:"activationId,omitempty"`
	ActivationType      ActivationValue             `json:"activationType,omitempty"`
	AcknowledgeWarnings []string                    `json:"acknowledgeWarnings,omitempty"`
	ComplianceRecord    *ActivationComplianceRecord `json:"complianceRecord,omitempty"`
	FastPush            bool                        `json:"fastPush,omitempty"`
	IgnoreHTTPErrors    bool                        `json:"ignoreHttpErrors,omitempty"`
	PropertyName        string                      `json:"propertyName,omitempty"`
	PropertyID          string                      `json:"propertyId,omitempty"`
	PropertyVersion     int                         `json:"propertyVersion"`
	Network             NetworkValue                `json:"network"`
	Status              StatusValue                 `json:"status,omitempty"`
	SubmitDate          string                      `json:"submitDate,omitempty"`
	UpdateDate          string                      `json:"updateDate,omitempty"`
	Note                string                      `json:"note,omitempty"`
	NotifyEmails        []string                    `json:"notifyEmails"`
	StatusChange        chan bool                   `json:"-"`
	// contains filtered or unexported fields
}

Activation represents a property activation resource

func NewActivation

func NewActivation(parent *Activations) *Activation

NewActivation creates a new Activation

func (*Activation) Cancel

func (activation *Activation) Cancel(property *Property) error

Cancel an activation in progress

API Docs: https://developer.akamai.com/api/luna/papi/resources.html#cancelapendingactivation Endpoint: DELETE /papi/v1/properties/{propertyId}/activations/{activationId}{?contractId,groupId}

func (*Activation) GetActivation

func (activation *Activation) GetActivation(property *Property) (time.Duration, error)

GetActivation populates the Activation resource

API Docs: https://developer.akamai.com/api/luna/papi/resources.html#getanactivation Endpoint: GET /papi/v1/properties/{propertyId}/activations/{activationId}{?contractId,groupId}

func (*Activation) Init

func (activation *Activation) Init()

func (*Activation) PollStatus

func (activation *Activation) PollStatus(property *Property) bool

PollStatus will responsibly poll till the property is active or an error occurs

The Activation.StatusChange is a channel that can be used to block on status changes. If a new valid status is returned, true will be sent to the channel, otherwise, false will be sent.

go activation.PollStatus(property)
for activation.Status != edgegrid.StatusActive {
	select {
	case statusChanged := <-activation.StatusChange:
		if statusChanged == false {
			break
		}
	case <-time.After(time.Minute * 30):
		break
	}
}

if activation.Status == edgegrid.StatusActive {
	// Activation succeeded
}

func (*Activation) Save

func (activation *Activation) Save(property *Property, acknowledgeWarnings bool) error

Save activates a given property

If acknowledgeWarnings is true and warnings are returned on the first attempt, a second attempt is made, acknowledging the warnings.

See: Property.Activate() API Docs: https://developer.akamai.com/api/luna/papi/resources.html#activateaproperty Endpoint: POST /papi/v1/properties/{propertyId}/activations/{?contractId,groupId}

type ActivationComplianceRecord

type ActivationComplianceRecord struct {
	NoncomplianceReason string `json:"noncomplianceReason,omitempty"`
}

type ActivationValue

type ActivationValue string

ActivationValue is used to create an "enum" of possible Activation.ActivationType values

type Activations

type Activations struct {
	client.Resource
	AccountID   string `json:"accountId"`
	ContractID  string `json:"contractId"`
	GroupID     string `json:"groupId"`
	Activations struct {
		Items []*Activation `json:"items"`
	} `json:"activations"`
}

Activations is a collection of property activations

func NewActivations

func NewActivations() *Activations

NewActivations creates a new Activations

func (*Activations) GetActivations

func (activations *Activations) GetActivations(property *Property) error

GetActivations retrieves activation data for a given property

See: Property.GetActivations() API Docs: https://developer.akamai.com/api/luna/papi/resources.html#listactivations Endpoint: GET /papi/v1/properties/{propertyId}/activations/{?contractId,groupId}

func (*Activations) GetLatestActivation

func (activations *Activations) GetLatestActivation(network NetworkValue, status StatusValue) (*Activation, error)

GetLatestActivation gets the latest activation for the specified network

Default to NetworkProduction. Pass in a status to check for, defaults to StatusActive

func (*Activations) GetLatestProductionActivation

func (activations *Activations) GetLatestProductionActivation(status StatusValue) (*Activation, error)

GetLatestProductionActivation retrieves the latest activation for the production network

Pass in a status to check for, defaults to StatusActive

func (*Activations) GetLatestStagingActivation

func (activations *Activations) GetLatestStagingActivation(status StatusValue) (*Activation, error)

GetLatestStagingActivation retrieves the latest activation for the staging network

Pass in a status to check for, defaults to StatusActive

type AvailableBehavior

type AvailableBehavior struct {
	client.Resource

	Name       string `json:"name"`
	SchemaLink string `json:"schemaLink"`
	// contains filtered or unexported fields
}

AvailableBehavior represents an available behavior resource

func NewAvailableBehavior

func NewAvailableBehavior(parent *AvailableBehaviors) *AvailableBehavior

NewAvailableBehavior creates a new AvailableBehavior

func (*AvailableBehavior) GetSchema

func (behavior *AvailableBehavior) GetSchema() (*gojsonschema.Schema, error)

GetSchema retrieves the JSON schema for an available behavior

type AvailableBehaviors

type AvailableBehaviors struct {
	client.Resource
	ContractID string `json:"contractId"`
	GroupID    string `json:"groupId"`
	ProductID  string `json:"productId"`
	RuleFormat string `json:"ruleFormat"`
	Behaviors  struct {
		Items []AvailableBehavior `json:"items"`
	} `json:"behaviors"`
}

AvailableBehaviors represents a collection of available rule behaviors

func GetAvailableBehaviors

func GetAvailableBehaviors(property *Property) (*AvailableBehaviors, error)

GetAvailableBehaviors retrieves all available behaviors for a property

func NewAvailableBehaviors

func NewAvailableBehaviors() *AvailableBehaviors

NewAvailableBehaviors creates a new AvailableBehaviors

func (*AvailableBehaviors) GetAvailableBehaviors

func (availableBehaviors *AvailableBehaviors) GetAvailableBehaviors(property *Property) error

GetAvailableBehaviors retrieves available behaviors for a given property

See: Property.GetAvailableBehaviors API Docs: https://developer.akamai.com/api/luna/papi/resources.html#listavailablebehaviors Endpoint: GET /papi/v1/properties/{propertyId}/versions/{propertyVersion}/available-behaviors{?contractId,groupId}

func (*AvailableBehaviors) PostUnmarshalJSON

func (availableBehaviors *AvailableBehaviors) PostUnmarshalJSON() error

PostUnmarshalJSON is called after JSON unmarshaling into EdgeHostnames

See: jsonhooks-v1/jsonhooks.Unmarshal()

type AvailableCriteria

type AvailableCriteria struct {
	client.Resource
	ContractID        string `json:"contractId"`
	GroupID           string `json:"groupId"`
	ProductID         string `json:"productId"`
	RuleFormat        string `json:"ruleFormat"`
	AvailableCriteria struct {
		Items []struct {
			Name       string `json:"name"`
			SchemaLink string `json:"schemaLink"`
		} `json:"items"`
	} `json:"availableCriteria"`
}

AvailableCriteria represents a collection of available rule criteria

func GetAvailableCriteria

func GetAvailableCriteria(property *Property) (*AvailableCriteria, error)

GetAvailableCriteria retrieves all available criteria for a property

func NewAvailableCriteria

func NewAvailableCriteria() *AvailableCriteria

NewAvailableCriteria creates a new AvailableCriteria

func (*AvailableCriteria) GetAvailableCriteria

func (availableCriteria *AvailableCriteria) GetAvailableCriteria(property *Property) error

GetAvailableCriteria retrieves criteria available for a given property

API Docs: https://developer.akamai.com/api/luna/papi/resources.html#listavailablecriteria Endpoint: GET /papi/v1/properties/{propertyId}/versions/{propertyVersion}/available-criteria{?contractId,groupId}

type Behavior

type Behavior struct {
	client.Resource

	Name    string       `json:"name"`
	Options *OptionValue `json:"options"`
	// contains filtered or unexported fields
}

Behavior represents a rule behavior resource

func NewBehavior

func NewBehavior(parent *Rule) *Behavior

NewBehavior creates a new Behavior

type ClientSettings

type ClientSettings struct {
	client.Resource
	RuleFormat string `json:"ruleFormat"`
}

ClientSettings represents the PAPI client settings resource

func NewClientSettings

func NewClientSettings() *ClientSettings

NewClientSettings creates a new ClientSettings

func (*ClientSettings) GetClientSettings

func (clientSettings *ClientSettings) GetClientSettings() error

GetClientSettings populates ClientSettings

API Docs: https://developer.akamai.com/api/luna/papi/resources.html#getclientsettings Endpoint: GET /papi/v1/client-settings

func (*ClientSettings) Save

func (clientSettings *ClientSettings) Save() error

Save updates client settings

API Docs: https://developer.akamai.com/api/luna/papi/resources.html#updateclientsettings Endpoint: PUT /papi/v1/client-settings

type ClonePropertyFrom

type ClonePropertyFrom struct {
	client.Resource
	PropertyID           string `json:"propertyId"`
	Version              int    `json:"version"`
	CopyHostnames        bool   `json:"copyHostnames,omitempty"`
	CloneFromVersionEtag string `json:"cloneFromVersionEtag,omitempty"`
}

ClonePropertyFrom represents

func NewClonePropertyFrom

func NewClonePropertyFrom() *ClonePropertyFrom

NewClonePropertyFrom creates a new ClonePropertyFrom

type CnameTypeValue

type CnameTypeValue string

CnameTypeValue is used to create an "enum" of possible Hostname.CnameType values

const (
	// CnameTypeEdgeHostname Hostname.CnameType value EDGE_HOSTNAME
	CnameTypeEdgeHostname CnameTypeValue = "EDGE_HOSTNAME"
)

type Contract

type Contract struct {
	client.Resource

	ContractID       string `json:"contractId"`
	ContractTypeName string `json:"contractTypeName"`
	// contains filtered or unexported fields
}

Contract represents a property contract resource

func NewContract

func NewContract(parent *Contracts) *Contract

NewContract creates a new Contract

func (*Contract) GetContract

func (contract *Contract) GetContract() error

GetContract populates a Contract

func (*Contract) GetProducts

func (contract *Contract) GetProducts() (*Products, error)

GetProducts gets products associated with a contract

type Contracts

type Contracts struct {
	client.Resource
	AccountID string `json:"accountId"`
	Contracts struct {
		Items []*Contract `json:"items"`
	} `json:"contracts"`
}

Contracts represents a collection of property manager contracts

func GetContracts

func GetContracts() (*Contracts, error)

GetContracts retrieves all contracts

func NewContracts

func NewContracts() *Contracts

NewContracts creates a new Contracts

func (*Contracts) GetContracts

func (contracts *Contracts) GetContracts() error

GetContracts populates Contracts with contract data

API Docs: https://developer.akamai.com/api/luna/papi/resources.html#listcontracts Endpoint: GET /papi/v1/contracts

func (*Contracts) PostUnmarshalJSON

func (contracts *Contracts) PostUnmarshalJSON() error

PostUnmarshalJSON is called after JSON unmarshaling into EdgeHostnames

See: jsonhooks-v1/jsonhooks.Unmarshal()

type CpCode

type CpCode struct {
	client.Resource

	CpcodeID    string    `json:"cpcodeId,omitempty"`
	CpcodeName  string    `json:"cpcodeName"`
	ProductID   string    `json:"productId,omitempty"`
	ProductIDs  []string  `json:"productIds,omitempty"`
	CreatedDate time.Time `json:"createdDate,omitempty"`
	// contains filtered or unexported fields
}

CpCode represents a single CP Code

API Docs: https://developer.akamai.com/api/luna/papi/data.html#cpcode

func NewCpCode

func NewCpCode(parent *CpCodes) *CpCode

NewCpCode creates a new *CpCode

func (*CpCode) GetCpCode

func (cpcode *CpCode) GetCpCode() error

GetCpCode populates the *CpCode with it's data

API Docs: https://developer.akamai.com/api/luna/papi/resources.html#getacpcode Endpoint: GET /papi/v1/cpcodes/{cpcodeId}{?contractId,groupId}

func (*CpCode) ID

func (cpcode *CpCode) ID() int

ID retrieves a CP Codes integer ID

PAPI Behaviors require the integer ID, rather than the prefixed string returned

func (*CpCode) Save

func (cpcode *CpCode) Save() error

Save will create a new CP Code. You cannot update a CP Code; trying to do so will result in an error.

API Docs: https://developer.akamai.com/api/luna/papi/resources.html#createanewcpcode Endpoint: POST /papi/v1/cpcodes/{?contractId,groupId}

type CpCodes

type CpCodes struct {
	client.Resource
	AccountID  string    `json:"accountId"`
	Contract   *Contract `json:"-"`
	ContractID string    `json:"contractId"`
	GroupID    string    `json:"groupId"`
	Group      *Group    `json:"-"`
	CpCodes    struct {
		Items []*CpCode `json:"items"`
	} `json:"cpcodes"`
}

CpCodes represents a collection of CP Codes

See: CpCodes.GetCpCodes() API Docs: https://developer.akamai.com/api/luna/papi/data.html#cpcode

func GetCpCodes

func GetCpCodes(contract *Contract, group *Group) (*CpCodes, error)

GetCpCodes creates a new CpCodes struct and populates it with all CP Codes associated with a contract/group

API Docs: https://developer.akamai.com/api/luna/papi/resources.html#listcpcodes

func NewCpCodes

func NewCpCodes(contract *Contract, group *Group) *CpCodes

NewCpCodes creates a new *CpCodes

func (*CpCodes) AddCpCode

func (cpcodes *CpCodes) AddCpCode(cpcode *CpCode)

func (*CpCodes) FindCpCode

func (cpcodes *CpCodes) FindCpCode(nameOrId string) (*CpCode, error)

func (*CpCodes) GetCpCodes

func (cpcodes *CpCodes) GetCpCodes() error

GetCpCodes populates a *CpCodes with it's related CP Codes

API Docs: https://developer.akamai.com/api/luna/papi/resources.html#listcpcodes Endpoint: GET /papi/v1/cpcodes/{?contractId,groupId}

func (*CpCodes) NewCpCode

func (cpcodes *CpCodes) NewCpCode() *CpCode

NewCpCode creates a new *CpCode associated with this *CpCodes as it's parent.

func (*CpCodes) PostUnmarshalJSON

func (cpcodes *CpCodes) PostUnmarshalJSON() error

PostUnmarshalJSON is called after UnmarshalJSON to setup the structs internal state. The cpcodes.Complete channel is utilized to communicate full completion.

type Criteria

type Criteria struct {
	client.Resource

	Name    string       `json:"name"`
	Options *OptionValue `json:"options"`
	// contains filtered or unexported fields
}

Criteria represents a rule criteria resource

func NewCriteria

func NewCriteria(parent *Rule) *Criteria

NewCriteria creates a new Criteria

type EdgeHostname

type EdgeHostname struct {
	client.Resource

	EdgeHostnameID         string      `json:"edgeHostnameId,omitempty"`
	EdgeHostnameDomain     string      `json:"edgeHostnameDomain,omitempty"`
	ProductID              string      `json:"productId"`
	DomainPrefix           string      `json:"domainPrefix"`
	DomainSuffix           string      `json:"domainSuffix"`
	Status                 StatusValue `json:"status,omitempty"`
	Secure                 bool        `json:"secure,omitempty"`
	IPVersionBehavior      string      `json:"ipVersionBehavior,omitempty"`
	MapDetailsSerialNumber int         `json:"mapDetails:serialNumber,omitempty"`
	MapDetailsSlotNumber   int         `json:"mapDetails:slotNumber,omitempty"`
	MapDetailsMapDomain    string      `json:"mapDetails:mapDomain,omitempty"`
	StatusChange           chan bool   `json:"-"`
	// contains filtered or unexported fields
}

EdgeHostname represents an Edge Hostname resource

func NewEdgeHostname

func NewEdgeHostname(edgeHostnames *EdgeHostnames) *EdgeHostname

NewEdgeHostname creates a new EdgeHostname

func (*EdgeHostname) GetEdgeHostname

func (edgeHostname *EdgeHostname) GetEdgeHostname(options string) error

GetEdgeHostname populates EdgeHostname with data

API Docs: https://developer.akamai.com/api/luna/papi/resources.html#getanedgehostname Endpoint: GET /papi/v1/edgehostnames/{edgeHostnameId}{?contractId,groupId,options}

func (*EdgeHostname) Init

func (edgeHostname *EdgeHostname) Init()

func (*EdgeHostname) PollStatus

func (edgeHostname *EdgeHostname) PollStatus(options string) bool

PollStatus will responsibly poll till the property is active or an error occurs

The EdgeHostname.StatusChange is a channel that can be used to block on status changes. If a new valid status is returned, true will be sent to the channel, otherwise, false will be sent.

go edgeHostname.PollStatus("")
for edgeHostname.Status != edgegrid.StatusActive {
	select {
	case statusChanged := <-edgeHostname.StatusChange:
		if statusChanged == false {
			break
		}
	case <-time.After(time.Minute * 30):
		break
	}
}

if edgeHostname.Status == edgegrid.StatusActive {
	// EdgeHostname activated successfully
}

func (*EdgeHostname) Save

func (edgeHostname *EdgeHostname) Save(options string) error

Save creates a new Edge Hostname

API Docs: https://developer.akamai.com/api/luna/papi/resources.html#createanewedgehostname Endpoint: POST /papi/v1/edgehostnames/{?contractId,groupId,options}

type EdgeHostnames

type EdgeHostnames struct {
	client.Resource
	AccountID     string `json:"accountId"`
	ContractID    string `json:"contractId"`
	GroupID       string `json:"groupId"`
	EdgeHostnames struct {
		Items []*EdgeHostname `json:"items"`
	} `json:"edgeHostnames"`
}

EdgeHostnames is a collection for PAPI Edge Hostname resources

func GetEdgeHostnames

func GetEdgeHostnames(contract *Contract, group *Group, options string) (*EdgeHostnames, error)

GetEdgeHostnames retrieves all edge hostnames

func NewEdgeHostnames

func NewEdgeHostnames() *EdgeHostnames

NewEdgeHostnames creates a new EdgeHostnames

func (*EdgeHostnames) AddEdgeHostname

func (edgeHostnames *EdgeHostnames) AddEdgeHostname(edgeHostname *EdgeHostname)

func (*EdgeHostnames) FindEdgeHostname

func (edgeHostnames *EdgeHostnames) FindEdgeHostname(edgeHostname *EdgeHostname) (*EdgeHostname, error)

func (*EdgeHostnames) GetEdgeHostnames

func (edgeHostnames *EdgeHostnames) GetEdgeHostnames(contract *Contract, group *Group, options string) error

GetEdgeHostnames will populate EdgeHostnames with Edge Hostname data

API Docs: https://developer.akamai.com/api/luna/papi/resources.html#listedgehostnames Endpoint: GET /papi/v1/edgehostnames/{?contractId,groupId,options}

func (*EdgeHostnames) NewEdgeHostname

func (edgeHostnames *EdgeHostnames) NewEdgeHostname() *EdgeHostname

NewEdgeHostname creates a new EdgeHostname within a given EdgeHostnames

func (*EdgeHostnames) PostUnmarshalJSON

func (edgeHostnames *EdgeHostnames) PostUnmarshalJSON() error

PostUnmarshalJSON is called after JSON unmarshaling into EdgeHostnames

See: jsonhooks-v1/jsonhooks.Unmarshal()

type Group

type Group struct {
	client.Resource

	GroupName     string   `json:"groupName"`
	GroupID       string   `json:"groupId"`
	ParentGroupID string   `json:"parentGroupId,omitempty"`
	ContractIDs   []string `json:"contractIds"`
	// contains filtered or unexported fields
}

Group represents a group resource

func NewGroup

func NewGroup(parent *Groups) *Group

NewGroup creates a new Group

func (*Group) GetCpCodes

func (group *Group) GetCpCodes(contract *Contract) (*CpCodes, error)

GetCpCodes retrieves all CP codes associated with a given group and contract

func (*Group) GetEdgeHostnames

func (group *Group) GetEdgeHostnames(contract *Contract, options string) (*EdgeHostnames, error)

GetEdgeHostnames retrieves all Edge hostnames associated with a given group/contract

func (*Group) GetGroup

func (group *Group) GetGroup()

GetGroup populates a Group

func (*Group) GetProperties

func (group *Group) GetProperties(contract *Contract) (*Properties, error)

GetProperties retrieves all properties associated with a given group and contract

func (*Group) NewProperty

func (group *Group) NewProperty(contract *Contract) (*Property, error)

NewProperty creates a property associated with a given group/contract

type Groups

type Groups struct {
	client.Resource
	AccountID   string `json:"accountId"`
	AccountName string `json:"accountName"`
	Groups      struct {
		Items []*Group `json:"items"`
	} `json:"groups"`
}

Groups represents a collection of PAPI groups

func GetGroups

func GetGroups() (*Groups, error)

GetGroups retrieves all groups

func NewGroups

func NewGroups() *Groups

NewGroups creates a new Groups

func (*Groups) AddGroup

func (groups *Groups) AddGroup(newGroup *Group)

AddGroup adds a group to a Groups collection

func (*Groups) FindGroup

func (groups *Groups) FindGroup(name string) (*Group, error)

FindGroup finds a specific group by name

func (*Groups) GetGroups

func (groups *Groups) GetGroups() error

GetGroups populates Groups with group data

API Docs: https://developer.akamai.com/api/luna/papi/resources.html#listgroups Endpoint: GET /papi/v1/groups/

func (*Groups) PostUnmarshalJSON

func (groups *Groups) PostUnmarshalJSON() error

PostUnmarshalJSON is called after JSON unmarshaling into EdgeHostnames

See: jsonhooks-v1/jsonhooks.Unmarshal()

type Hostname

type Hostname struct {
	client.Resource

	CnameType      CnameTypeValue `json:"cnameType"`
	EdgeHostnameID string         `json:"edgeHostnameId"`
	CnameFrom      string         `json:"cnameFrom"`
	CnameTo        string         `json:"cnameTo,omitempty"`
	// contains filtered or unexported fields
}

Hostname represents a property hostname resource

func NewHostname

func NewHostname(parent *Hostnames) *Hostname

NewHostname creates a new Hostname

type Hostnames

type Hostnames struct {
	client.Resource
	AccountID       string `json:"accountId"`
	ContractID      string `json:"contractId"`
	GroupID         string `json:"groupId"`
	PropertyID      string `json:"propertyId"`
	PropertyVersion int    `json:"propertyVersion"`
	Etag            string `json:"etag"`
	Hostnames       struct {
		Items []*Hostname `json:"items"`
	} `json:"hostnames"`
}

Hostnames is a collection of Property Hostnames

func NewHostnames

func NewHostnames() *Hostnames

NewHostnames creates a new Hostnames

func (*Hostnames) GetHostnames

func (hostnames *Hostnames) GetHostnames(version *Version) error

GetHostnames retrieves hostnames assigned to a given property

If no version is given, the latest version is used

See: Property.GetHostnames() API Docs: https://developer.akamai.com/api/luna/papi/resources.html#listapropertyshostnames Endpoint: GET /papi/v1/properties/{propertyId}/versions/{propertyVersion}/hostnames/{?contractId,groupId}

func (*Hostnames) NewHostname

func (hostnames *Hostnames) NewHostname() *Hostname

NewHostname creates a new Hostname within a given Hostnames

func (*Hostnames) PostUnmarshalJSON

func (hostnames *Hostnames) PostUnmarshalJSON() error

PostUnmarshalJSON is called after JSON unmarshaling into EdgeHostnames

See: jsonhooks-v1/jsonhooks.Unmarshal()

func (*Hostnames) Save

func (hostnames *Hostnames) Save() error

Save updates a properties hostnames

type NetworkValue

type NetworkValue string

NetworkValue is used to create an "enum" of possible Activation.Network values

type OptionValue

type OptionValue client.JSONBody

OptionValue represents a generic option value

OptionValue is a map with string keys, and any type of value. You can nest OptionValues as necessary to create more complex values.

type Product

type Product struct {
	client.Resource

	ProductName string `json:"productName"`
	ProductID   string `json:"productId"`
	// contains filtered or unexported fields
}

Product represents a product resource

func NewProduct

func NewProduct(parent *Products) *Product

NewProduct creates a new Product

type Products

type Products struct {
	client.Resource
	AccountID  string `json:"accountId"`
	ContractID string `json:"contractId"`
	Products   struct {
		Items []*Product `json:"items"`
	} `json:"products"`
}

Products represents a collection of products

func GetProducts

func GetProducts(contract *Contract) (*Products, error)

GetProducts retrieves all products

func NewProducts

func NewProducts() *Products

NewProducts creates a new Products

func (*Products) GetProducts

func (products *Products) GetProducts(contract *Contract) error

GetProducts populates Products with product data

API Docs: https://developer.akamai.com/api/luna/papi/resources.html#listproducts Endpoint: GET /papi/v1/products/{?contractId}

func (*Products) PostUnmarshalJSON

func (products *Products) PostUnmarshalJSON() error

PostUnmarshalJSON is called after JSON unmarshaling into EdgeHostnames

See: jsonhooks-v1/jsonhooks.Unmarshal()

type Properties

type Properties struct {
	client.Resource
	Properties struct {
		Items []*Property `json:"items"`
	} `json:"properties"`
}

Properties is a collection of PAPI Property resources

func GetProperties

func GetProperties(contract *Contract, group *Group) (*Properties, error)

GetProperties retrieves all properties for a given contract/group

func NewProperties

func NewProperties() *Properties

NewProperties creates a new Properties

func (*Properties) AddProperty

func (properties *Properties) AddProperty(newProperty *Property)

AddProperty adds a property to the collection, if the property already exists in the collection it will be replaced.

func (*Properties) FindProperty

func (properties *Properties) FindProperty(name string) (*Property, error)

FindProperty finds a property by name within the collection

func (*Properties) GetProperties

func (properties *Properties) GetProperties(contract *Contract, group *Group) error

GetProperties populates Properties with property data

API Docs: https://developer.akamai.com/api/luna/papi/resources.html#listproperties Endpoint: GET /papi/v1/properties/{?contractId,groupId}

func (*Properties) NewProperty

func (properties *Properties) NewProperty(contract *Contract, group *Group) *Property

NewProperty creates a new property associated with the collection

func (*Properties) PostUnmarshalJSON

func (properties *Properties) PostUnmarshalJSON() error

PostUnmarshalJSON is called after JSON unmarshaling into EdgeHostnames

See: jsonhooks-v1/jsonhooks.Unmarshal()

type Property

type Property struct {
	client.Resource

	AccountID         string             `json:"accountId,omitempty"`
	Contract          *Contract          `json:"-"`
	Group             *Group             `json:"-"`
	ContractID        string             `json:"contractId,omitempty"`
	GroupID           string             `json:"groupId,omitempty"`
	PropertyID        string             `json:"propertyId,omitempty"`
	PropertyName      string             `json:"propertyName"`
	LatestVersion     int                `json:"latestVersion,omitempty"`
	StagingVersion    int                `json:"stagingVersion,omitempty"`
	ProductionVersion int                `json:"productionVersion,omitempty"`
	Note              string             `json:"note,omitempty"`
	ProductID         string             `json:"productId,omitempty"`
	CloneFrom         *ClonePropertyFrom `json:"cloneFrom"`
	// contains filtered or unexported fields
}

Property represents a PAPI Property

func NewProperty

func NewProperty(parent *Properties) *Property

NewProperty creates a new Property

func (*Property) Activate

func (property *Property) Activate(activation *Activation, acknowledgeWarnings bool) error

Activate activates a given property

If acknowledgeWarnings is true and warnings are returned on the first attempt, a second attempt is made, acknowledging the warnings.

See: Activation.Save() API Docs: https://developer.akamai.com/api/luna/papi/resources.html#activateaproperty Endpoint: POST /papi/v1/properties/{propertyId}/activations/{?contractId,groupId}

func (*Property) Delete

func (property *Property) Delete() error

Delete a property

API Docs: https://developer.akamai.com/api/luna/papi/resources.html#removeaproperty Endpoint: DELETE /papi/v1/properties/{propertyId}{?contractId,groupId}

func (*Property) GetActivations

func (property *Property) GetActivations() (*Activations, error)

GetActivations retrieves activation data for a given property

See: Activations.GetActivations() API Docs: https://developer.akamai.com/api/luna/papi/resources.html#listactivations Endpoint: GET /papi/v1/properties/{propertyId}/activations/{?contractId,groupId}

func (*Property) GetAvailableBehaviors

func (property *Property) GetAvailableBehaviors() (*AvailableBehaviors, error)

GetAvailableBehaviors retrieves available behaviors for a given property

See: AvailableBehaviors.GetAvailableBehaviors API Docs: https://developer.akamai.com/api/luna/papi/resources.html#listavailablebehaviors Endpoint: GET /papi/v1/properties/{propertyId}/versions/{propertyVersion}/available-behaviors{?contractId,groupId}

func (*Property) GetHostnames

func (property *Property) GetHostnames(version *Version) (*Hostnames, error)

GetHostnames retrieves hostnames assigned to a given property

If no version is given, the latest version is used

See: Hostnames.GetHostnames() API Docs: https://developer.akamai.com/api/luna/papi/resources.html#listapropertyshostnames Endpoint: GET /papi/v1/properties/{propertyId}/versions/{propertyVersion}/hostnames/{?contractId,groupId}

func (*Property) GetLatestVersion

func (property *Property) GetLatestVersion(activatedOn NetworkValue) (*Version, error)

GetLatestVersion gets the latest active version, optionally of a given network

See: Versions.GetLatestVersion() API Docs: https://developer.akamai.com/api/luna/papi/resources.html#getthelatestversion Endpoint: GET /papi/v1/properties/{propertyId}/versions/latest{?contractId,groupId,activatedOn}

func (*Property) GetProperty

func (property *Property) GetProperty() error

GetProperty populates a Property

API Docs: https://developer.akamai.com/api/luna/papi/resources.html#getaproperty Endpoint: GET /papi/v1/properties/{propertyId}{?contractId,groupId}

func (*Property) GetRules

func (property *Property) GetRules() (*Rules, error)

GetRules retrieves rules for a property

See: Rules.GetRules API Docs: https://developer.akamai.com/api/luna/papi/resources.html#getaruletree Endpoint: GET /papi/v1/properties/{propertyId}/versions/{propertyVersion}/rules/{?contractId,groupId}

func (*Property) GetRulesDigest

func (property *Property) GetRulesDigest() (string, error)

GetRulesDigest fetches the Etag for a rule tree

See: Rules.GetRulesDigest() API Docs: https://developer.akamai.com/api/luna/papi/resources.html#getaruletreesdigest Endpoint: HEAD /papi/v1/properties/{propertyId}/versions/{propertyVersion}/rules/{?contractId,groupId}

func (*Property) GetVersions

func (property *Property) GetVersions() (*Versions, error)

GetVersions retrieves all versions for a a given property

See: Versions.GetVersions() API Docs: https://developer.akamai.com/api/luna/papi/resources.html#listversions Endpoint: GET /papi/v1/properties/{propertyId}/versions/{?contractId,groupId}

func (*Property) PostUnmarshalJSON

func (property *Property) PostUnmarshalJSON() error

PostUnmarshalJSON is called after JSON unmarshaling into EdgeHostnames

See: jsonhooks-v1/jsonhooks.Unmarshal()

func (*Property) PreMarshalJSON

func (property *Property) PreMarshalJSON() error

PreMarshalJSON is called before JSON marshaling

See: jsonhooks-v1/json.Marshal()

func (*Property) Save

func (property *Property) Save() error

Save will create a property, optionally cloned from another property

API Docs: https://developer.akamai.com/api/luna/papi/resources.html#createorcloneaproperty Endpoint: POST /papi/v1/properties/{?contractId,groupId}

type Rule

type Rule struct {
	client.Resource

	Depth               int                          `json:"-"`
	Name                string                       `json:"name"`
	Criteria            []*Criteria                  `json:"criteria,omitempty"`
	Behaviors           []*Behavior                  `json:"behaviors,omitempty"`
	Children            []*Rule                      `json:"children,omitempty"`
	Comments            string                       `json:"comments,omitempty"`
	CriteriaLocked      bool                         `json:"criteriaLocked,omitempty"`
	CriteriaMustSatisfy RuleCriteriaMustSatisfyValue `json:"criteriaMustSatisfy,omitempty"`
	UUID                string                       `json:"uuid,omitempty"`
	Options             struct {
		IsSecure bool `json:"is_secure,omitempty"`
	} `json:"options,omitempty"`
	// contains filtered or unexported fields
}

Rule represents a property rule resource

func NewRule

func NewRule(parent *Rules) *Rule

NewRule creates a new Rule

func (*Rule) AddBehavior

func (rule *Rule) AddBehavior(behavior *Behavior)

AddBehavior appends a rule behavior

func (*Rule) AddChildRule

func (rule *Rule) AddChildRule(child *Rule)

AddChildRule appends a child rule

func (*Rule) AddCriteria

func (rule *Rule) AddCriteria(criteria *Criteria)

AddCriteria appends a rule criteria

func (*Rule) GetChildren

func (rule *Rule) GetChildren(depth int, limit int) []*Rule

GetChildren recurses a Rule tree and retrieves all child rules

type RuleCriteriaMustSatisfyValue

type RuleCriteriaMustSatisfyValue string
const (
	RuleCriteriaMustSatisfyAll RuleCriteriaMustSatisfyValue = "any"
	RuleCriteriaMustSatisfyAny RuleCriteriaMustSatisfyValue = "all"
)

type RuleErrors

type RuleErrors struct {
	client.Resource
	Type         string `json:"type"`
	Title        string `json:"title"`
	Detail       string `json:"detail"`
	Instance     string `json:"instance"`
	BehaviorName string `json:"behaviorName"`
}

RuleErrors represents an validate error returned for a rule

func NewRuleErrors

func NewRuleErrors() *RuleErrors

NewRuleErrors creates a new RuleErrors

type RuleFormats

type RuleFormats struct {
	client.Resource
	RuleFormats struct {
		Items []string `json:"items"`
	} `json:"ruleFormats"`
}

RuleFormats is a collection of available rule formats

func NewRuleFormats

func NewRuleFormats() *RuleFormats

NewRuleFormats creates a new RuleFormats

func (*RuleFormats) GetLatest

func (ruleFormats *RuleFormats) GetLatest() (string, error)

func (*RuleFormats) GetRuleFormats

func (ruleFormats *RuleFormats) GetRuleFormats() error

GetRuleFormats populates RuleFormats

API Docs: https://developer.akamai.com/api/luna/papi/resources.html#listruleformats Endpoint: GET /papi/v1/rule-formats

func (*RuleFormats) GetSchema

func (ruleFormats *RuleFormats) GetSchema(product string, ruleFormat string) (*gojsonschema.Schema, error)

GetSchema fetches the schema for a given product and rule format

API Docs: https://developer.akamai.com/api/luna/papi/resources.html#getaruleformatsschema Endpoint: /papi/v1/schemas/products/{productId}/{ruleFormat}

type Rules

type Rules struct {
	client.Resource
	AccountID       string        `json:"accountId"`
	ContractID      string        `json:"contractId"`
	GroupID         string        `json:"groupId"`
	PropertyID      string        `json:"propertyId"`
	PropertyVersion int           `json:"propertyVersion"`
	Etag            string        `json:"etag"`
	RuleFormat      string        `json:"ruleFormat"`
	Rules           *Rule         `json:"rules"`
	Errors          []*RuleErrors `json:"errors,omitempty"`
}

Rules is a collection of property rules

func NewRules

func NewRules() *Rules

NewRules creates a new Rules

func (*Rules) AddBehaviorOptions

func (rules *Rules) AddBehaviorOptions(path string, newOptions OptionValue) error

AddBehaviorOptions adds/replaces options on a given behavior path

path is a / delimited path from the root of the rule set to the behavior. Individual existing options are overwritten. To replace all options, see SetBehaviorOptions instead.

For example, to change the CP Code, the behavior exists at the root, and is called "cpCode", making the path, "/cpCode":

rules.AddBehaviorOptions(
	"/cpCode",
	edgegrid.OptionValue{
		"value": edgegrid.OptionValue{
			"id": cpcode,
		},
	},
)

The adaptiveImageCompression behavior defaults to being under the Performance -> JPEG Images, making the path "/Performance/JPEG Images/adaptiveImageCompression":

rules.AddBehaviorOptions(
	"/Performance/JPEG Images/adaptiveImageCompression",
	edgegrid.OptionValue{
		"tier3StandardCompressionValue": 30,
	},
)

This will only change the "tier3StandardCompressionValue" option value.

func (*Rules) AddChildBehavior

func (rules *Rules) AddChildBehavior(path string, behavior *Behavior) error

AddChildBehavior adds a behavior as a child of the given rule path

If the behavior already exists, it's options are merged with the existing options.

func (*Rules) AddChildCriteria

func (rules *Rules) AddChildCriteria(path string, criteria *Criteria) error

AddChildCriteria adds criteria as a child of the rule specified by the given path

If the criteria already exists it's options are added to the existing criteria.

func (*Rules) AddChildRule

func (rules *Rules) AddChildRule(path string, rule *Rule) error

AddChildRule adds a rule as a child of the rule specified by the given path

If the rule already exists, criteria, behaviors, and child rules are added to the existing rule.

func (*Rules) AddCriteriaOptions

func (rules *Rules) AddCriteriaOptions(path string, newOptions OptionValue) error

AddCriteriaOptions adds/replaces options on a given Criteria path

path is a / delimited path from the root of the rule set to the criteria. Individual existing options are overwritten. To replace all options, see SetCriteriaOptions instead.

func (*Rules) FindBehavior

func (rules *Rules) FindBehavior(path string) (*Behavior, error)

FindBehavior locates a specific behavior by path

See SetBehaviorOptions and AddBehaviorOptions for examples of paths.

func (*Rules) FindCriteria

func (rules *Rules) FindCriteria(path string) (*Criteria, error)

FindCriteria locates a specific Critieria by path

See SetCriteriaOptions and AddCriteriaOptions for examples of paths.

func (*Rules) FindParentRule

func (rules *Rules) FindParentRule(path string) (*Rule, error)

Find the parent rule for a given rule, criteria, or behavior path

func (*Rules) FindRule

func (rules *Rules) FindRule(path string) (*Rule, error)

FindRule locates a specific rule by path

See SetBehaviorOptions and AddBehaviorOptions for examples of paths.

func (*Rules) Freeze

func (rules *Rules) Freeze(format string) error

Freeze pins a properties rule set to a specific rule set version

func (*Rules) GetAllRules

func (rules *Rules) GetAllRules() []*Rule

GetAllRules returns a flattened rule tree for easy iteration

Each Rule has a Depth property that makes it possible to identify it's original placement in the tree.

func (*Rules) GetRules

func (rules *Rules) GetRules(property *Property) error

GetRules populates Rules with rule data for a given property

See: Property.GetRules API Docs: https://developer.akamai.com/api/luna/papi/resources.html#getaruletree Endpoint: GET /papi/v1/properties/{propertyId}/versions/{propertyVersion}/rules/{?contractId,groupId}

func (*Rules) GetRulesDigest

func (rules *Rules) GetRulesDigest(property *Property) (string, error)

GetRulesDigest fetches the Etag for a rule tree

See: Property.GetRulesDigest() API Docs: https://developer.akamai.com/api/luna/papi/resources.html#getaruletreesdigest Endpoint: HEAD /papi/v1/properties/{propertyId}/versions/{propertyVersion}/rules/{?contractId,groupId}

func (*Rules) PostUnmarshalJSON

func (rules *Rules) PostUnmarshalJSON() error

PostUnmarshalJSON is called after JSON unmarshaling into EdgeHostnames

See: jsonhooks-v1/jsonhooks.Unmarshal()

func (*Rules) PreMarshalJSON

func (rules *Rules) PreMarshalJSON() error

PreMarshalJSON is called before JSON marshaling

See: jsonhooks-v1/json.Marshal()

func (*Rules) Save

func (rules *Rules) Save() error

Save creates/updates a rule tree for a property

API Docs: https://developer.akamai.com/api/luna/papi/resources.html#updatearuletree Endpoint: PUT /papi/v1/properties/{propertyId}/versions/{propertyVersion}/rules/{?contractId,groupId}

func (*Rules) SetBehaviorOptions

func (rules *Rules) SetBehaviorOptions(path string, newOptions OptionValue) error

SetBehaviorOptions sets the options on a given behavior path

path is a / delimited path from the root of the rule set to the behavior. All existing options are overwritten. To add/replace options see AddBehaviorOptions instead.

For example, to set the CP Code, the behavior exists at the root, and is called "cpCode", making the path, "/cpCode":

rules.SetBehaviorOptions(
	"/cpCode",
	edgegrid.OptionValue{
		"value": edgegrid.OptionValue{
			"id": cpcode,
		},
	},
)

The adaptiveImageCompression behavior defaults to being under the Performance -> JPEG Images, making the path "/Performance/JPEG Images/adaptiveImageCompression":

rules.SetBehaviorOptions(
	"/Performance/JPEG Images/adaptiveImageCompression"",
	edgegrid.OptionValue{
		"tier3StandardCompressionValue": 30,
	},
)

However, this would replace all other options for that behavior, meaning the example would fail to validate without the other required options.

func (*Rules) SetChildBehavior

func (rules *Rules) SetChildBehavior(path string, behavior *Behavior) error

SetChildBehavior adds a behavior as a child of the given rule path

If the behavior already exists it is replaced with the given behavior

func (*Rules) SetChildCriteria

func (rules *Rules) SetChildCriteria(path string, criteria *Criteria) error

SetChildCriteria adds criteria as a child of the rule specified by the given path

If the criteria already exists it will replace the existing criteria.

func (*Rules) SetChildRule

func (rules *Rules) SetChildRule(path string, rule *Rule) error

SetChildRule adds a rule as a child of the rule specified by the given path

If the rule already exists, it is replaced by the given rule.

func (*Rules) SetCriteriaOptions

func (rules *Rules) SetCriteriaOptions(path string, newOptions OptionValue) error

SetCriteriaOptions sets the options on a given criteria path

path is a / delimited path from the root of the rule set to the criteria. All existing options are overwritten. To add/replace options see AddCriteriaOptions instead.

type StatusValue

type StatusValue string

StatusValue is used to create an "enum" of possible Activation.Status values

type Version

type Version struct {
	client.Resource

	PropertyVersion       int         `json:"propertyVersion,omitempty"`
	UpdatedByUser         string      `json:"updatedByUser,omitempty"`
	UpdatedDate           time.Time   `json:"updatedDate,omitempty"`
	ProductionStatus      StatusValue `json:"productionStatus,omitempty"`
	StagingStatus         StatusValue `json:"stagingStatus,omitempty"`
	Etag                  string      `json:"etag,omitempty"`
	ProductID             string      `json:"productId,omitempty"`
	Note                  string      `json:"note,omitempty"`
	CreateFromVersion     int         `json:"createFromVersion,omitempty"`
	CreateFromVersionEtag string      `json:"createFromVersionEtag,omitempty"`
	// contains filtered or unexported fields
}

Version represents a Property Version

func NewVersion

func NewVersion(parent *Versions) *Version

NewVersion creates a new Version

func (*Version) GetVersion

func (version *Version) GetVersion(property *Property, getVersion int) error

GetVersion populates a Version

Api Docs: https://developer.akamai.com/api/luna/papi/resources.html#getaversion Endpoint: /papi/v1/properties/{propertyId}/versions/{propertyVersion}{?contractId,groupId}

func (*Version) HasBeenActivated

func (version *Version) HasBeenActivated(activatedOn NetworkValue) (bool, error)

HasBeenActivated determines if a given version has been activated, optionally on a specific network

func (*Version) Save

func (version *Version) Save() error

Save creates a new version

API Docs: https://developer.akamai.com/api/luna/papi/resources.html#createanewversion Endpoint: POST /papi/v1/properties/{propertyId}/versions/{?contractId,groupId}

type Versions

type Versions struct {
	client.Resource
	PropertyID   string `json:"propertyId"`
	PropertyName string `json:"propertyName"`
	AccountID    string `json:"accountId"`
	ContractID   string `json:"contractId"`
	GroupID      string `json:"groupId"`
	Versions     struct {
		Items []*Version `json:"items"`
	} `json:"versions"`
	RuleFormat string `json:"ruleFormat,omitempty"`
}

Versions contains a collection of Property Versions

func GetVersions

func GetVersions(property *Property) (*Versions, error)

GetVersions retrieves all versions for a given property

func NewVersions

func NewVersions() *Versions

NewVersions creates a new Versions

func (*Versions) AddVersion

func (versions *Versions) AddVersion(version *Version)

AddVersion adds or replaces a version within the collection

func (*Versions) GetLatestVersion

func (versions *Versions) GetLatestVersion(activatedOn NetworkValue) (*Version, error)

GetLatestVersion retrieves the latest Version for a property

See: Property.GetLatestVersion() API Docs: https://developer.akamai.com/api/luna/papi/resources.html#getthelatestversion Endpoint: GET /papi/v1/properties/{propertyId}/versions/latest{?contractId,groupId,activatedOn}

func (*Versions) GetVersions

func (versions *Versions) GetVersions(property *Property) error

GetVersions retrieves all versions for a a given property

See: Property.GetVersions() API Docs: https://developer.akamai.com/api/luna/papi/resources.html#listversions Endpoint: GET /papi/v1/properties/{propertyId}/versions/{?contractId,groupId}

func (*Versions) NewVersion

func (versions *Versions) NewVersion(createFromVersion *Version, useEtagStrict bool) *Version

NewVersion creates a new version associated with the Versions collection

func (*Versions) PostUnmarshalJSON

func (versions *Versions) PostUnmarshalJSON() error

PostUnmarshalJSON is called after JSON unmarshaling into EdgeHostnames

See: jsonhooks-v1/jsonhooks.Unmarshal()

Jump to

Keyboard shortcuts

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