akamai

package
v0.0.0-...-a493ebb Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2019 License: BSD-3-Clause Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RRTypeA         = "A"
	RRTypeAaaa      = "AAAA"
	RRTypeAfsdb     = "AFSDB"
	RRTypeAkamaiCdn = "AKAMAICDN"
	RRTypeAkamaiTlc = "AKAMAITLC"
	RRTypeCaa       = "CAA"
	RRTypeCname     = "CNAME"
	RRTypeHinfo     = "HINFO"
	RRTypeLoc       = "LOC"
	RRTypeMx        = "MX"
	RRTypeNaptr     = "NAPTR"
	RRTypeNs        = "NS"
	RRTypePtr       = "PTR"
	RRTypeRp        = "RP"
	RRTypeSrv       = "SRV"
	RRTypeSpf       = "SPF"
	RRTypeSshfp     = "SSHFP"
	RRTypeTlsa      = "TLSA"
	RRTypeTxt       = "TXT"
)

Resource record types supported by the Akamai FastDNS API

Variables

This section is empty.

Functions

func CheckResponse

func CheckResponse(r *http.Response) error

CheckResponse checks an API resonse for errors. If an error is found, it is returned. Errors are considered as anything outside of the 200 range of HTTP responses, with the exception being a 202 Accepted response.

Types

type AcceptedError

type AcceptedError struct {
	// Response body's raw contents
	Raw []byte
}

AcceptedError occurs when Akamai returns a 202 Accepted response. This means an asynchronous process has begun and is scheduled on the Akamai side. HTTP 202 is not an error, it's just used to indicate that the results are not ready yet, to check back soon.

func (*AcceptedError) Error

func (*AcceptedError) Error() string

type AkamaiError

type AkamaiError struct {
	Detail   string `json:"detail"`
	Instance string `json:"instance"`
	Status   int    `json:"status"`
	Title    string `json:"title"`
	Type     string `json:"type"`
}

AkamaiError is the error type of FastDNS v2 API.

func (*AkamaiError) Error

func (e *AkamaiError) Error() string

type ChangeList

type ChangeList struct {
	ChangeTag        string `json:"changeTag,omitempty"`
	LastModifiedDate string `json:"lastModifiedDate,omitempty"`
	Stale            bool   `json:"stale,omitempty"`
	Zone             string `json:"zone,omitempty"`
	ZoneVersionId    string `json:"zoneVersionId,omitempty"`
}

ChangeList holds metadata about a change list, including the particular version of a zone that the change list was based off when it was created.

type ChangeListMetadata

type ChangeListMetadata struct {
	Zone          *string   `json:"zone,omitempty"`
	Types         []*string `json:"types,omitempty"`
	Page          *int      `json:"page,omitempty"`
	PageSize      *int      `json:"pageSize,omitempty"`
	TotalElements *int      `json:"totalElements,omitempty"`
}

ChangeListMetadata holds metadata for a change list of record sets

type ChangeListOptions

type ChangeListOptions struct {
	Zone      string `url:"zone,omitempty"`
	Overwrite string `url:"overwrite,omitempty"`
	Page      int    `url:"page,omitempty"`
	PageSize  int    `url:"pageSize,omitempty"`
	Search    string `url:"search,omitempty"`
	ShowAll   bool   `url:"showAll,omitempty"`
	SortBy    string `url:"sortBy,omitempty"`
	Types     string `url:"types,omitempty"`
}

ChangeListOptions holds options to pass when creating change lists.

type ChangeListRecords

type ChangeListRecords struct {
	Metadata   *ChangeListMetadata `json:"metadata,omitempty"`
	Recordsets []*RecordSet        `json:"recordsets,omitempty"`
}

ChangeListRecords holds the current list of record sets from the perspective of a change list

type Client

type Client struct {

	// User agent used when communicating with the API.
	UserAgent string

	// BaseURL contains the API URL.
	BaseURL *url.URL

	// Credentials object to use when signing requests.
	Credentials *credentials.Credentials

	// Services of the Akamai API.
	FastDNSv2 *FastDNSv2Service
	// contains filtered or unexported fields
}

Client creates an Akamai client to make requests against the Akamai API.

func NewClient

func NewClient(httpClient *http.Client, cc *credentials.Credentials) (*Client, error)

NewClient returns an Akamai API client. If no httpClient is provided, http.DefaultClient is used. The Akamai API uses a unique base URL that is generated for every API client. If this isn't set then there is no default URL we can fall back to and we have to return an error.

func (*Client) Do

func (c *Client) Do(ctx context.Context, req *http.Request, v interface{}) (*Response, error)

Do sends the API request and returns the API response.

func (*Client) NewRequest

func (c *Client) NewRequest(method, urlStr string, body interface{}) (*http.Request, error)

NewRequest creates an API request.

type Contract

type Contract struct {
	ContractID       *string   `json:"contractId,omitempty"`
	ContractName     *string   `json:"contractName,omitempty"`
	ContractTypeName *string   `json:"contractTypeName,omitempty"`
	Features         []*string `json:"features,omitempty"`
	Permissions      []*string `json:"permissions,omitempty"`
	ZoneCount        int       `json:"zoneCount,omitempty"`
	MaximumZones     int       `json:"maximumZones,omitempty"`
}

Contract holds Akamai's Contract object type. It provides metadata about a customer's Akamai FastDNS account.

type FastDNSv2Service

type FastDNSv2Service service

FastDNSv2Service handles communication with the v2 FastDNS (beta) related endpoints of the Akamai API

func (*FastDNSv2Service) CreateChangeList

func (s *FastDNSv2Service) CreateChangeList(ctx context.Context, cl *ChangeListOptions) (*ChangeList, *Response, error)

CreateChangeList creates a new Change List based on the most recent version of a zone. No POST body is required, since the object is read-only.

Akamai API docs: https://developer.akamai.com/api/web_performance/fast_dns_zone_management/v2.html#postchangelists

func (*FastDNSv2Service) CreateRecordSet

func (s *FastDNSv2Service) CreateRecordSet(ctx context.Context, rs *RecordSetCreateRequest) (*RecordSet, *Response, error)

CreateRecordSet creates a new Record Set with the specified name and type.

https://developer.akamai.com/api/web_performance/fast_dns_zone_management/v2.html#postzonerecordset

func (*FastDNSv2Service) CreateZone

func (s *FastDNSv2Service) CreateZone(ctx context.Context, cid string, zone *ZoneCreateRequest) (*Zone, *Response, error)

CreateZone creates a new Zone

Akamai API docs: https://developer.akamai.com/api/web_performance/fast_dns_zone_management/v2.html#postzones

func (*FastDNSv2Service) DeleteChangeList

func (s *FastDNSv2Service) DeleteChangeList(ctx context.Context, zone string) (*Response, error)

DeleteChangeList removes an unneeded Change List

Akamai API docs: https://developer.akamai.com/api/web_performance/fast_dns_zone_management/v2.html#deletechangelist

func (*FastDNSv2Service) DeleteRecordSet

func (s *FastDNSv2Service) DeleteRecordSet(ctx context.Context, opt *RecordSetOptions) (*Response, error)

DeleteRecordSet removes an existing record set.

Akamai API docs: https://developer.akamai.com/api/web_performance/fast_dns_zone_management/v2.html#deletezonerecordset

func (*FastDNSv2Service) DeleteZone

DeleteZone deletes one or more Akamai zones. We set the query parameter force=true, as otherwise the delegation checks may cause the delete request in some instances to take hours.

Akamai API docs: https://developer.akamai.com/api/web_performance/fast_dns_zone_management/v2.html#postbulkzonedelete

func (*FastDNSv2Service) DeleteZoneResult

func (s *FastDNSv2Service) DeleteZoneResult(ctx context.Context, rid string) (*ZoneDeleteResult, *Response, error)

DeleteZoneResult retrieves the results from a completed DeleteZone request.

Akamai API docs: https://developer.akamai.com/api/web_performance/fast_dns_zone_management/v2.html#getbulkzonedeleteresult

func (*FastDNSv2Service) DeleteZoneStatus

func (s *FastDNSv2Service) DeleteZoneStatus(ctx context.Context, rid string) (*ZoneDeleteResponse, *Response, error)

DeleteZoneStatus checks the status of a DeleteZone request. Use the request ID that was given from teh output of the DeleteZone request.

Akamai API docs: https://developer.akamai.com/api/web_performance/fast_dns_zone_management/v2.html#getbulkzonedeletestatus

func (*FastDNSv2Service) GetChangeList

func (s *FastDNSv2Service) GetChangeList(ctx context.Context, zone string) (*ChangeList, *Response, error)

GetChangeList describes a Change List, showing its base zone version, last modified time, and current change tag.

Akamai API docs: https://developer.akamai.com/api/web_performance/fast_dns_zone_management/v2.html#getchangelist

func (*FastDNSv2Service) GetChangeListRecordSets

func (s *FastDNSv2Service) GetChangeListRecordSets(ctx context.Context, zone string, opt *ChangeListOptions) (*ChangeListRecords, *Response, error)

GetChangeListRecordSets retrieves the current list of record sets from the perspective of this change list. Any changes that have been added to this change list will be reflected in the list of record sets returned.

Akamai API docs: https://developer.akamai.com/api/web_performance/fast_dns_zone_management/v2.html#getchangelistrecordsets

func (*FastDNSv2Service) GetRecordSet

func (s *FastDNSv2Service) GetRecordSet(ctx context.Context, opt *RecordSetOptions) (*RecordSet, *Response, error)

GetRecordSet retrieves a single record set for the zone, record name, and record type specified in the URL.

Akamai API docs: https://developer.akamai.com/api/web_performance/fast_dns_zone_management/v2.html#getzonerecordset

func (*FastDNSv2Service) GetZone

func (s *FastDNSv2Service) GetZone(ctx context.Context, zone string) (*ZoneMetadata, *Response, error)

GetZone retrieves the metadata of a single zone. Does not include record sets.

Akamai API docs: https://developer.akamai.com/api/web_performance/fast_dns_zone_management/v2.html#getzone

func (*FastDNSv2Service) GetZoneContract

func (s *FastDNSv2Service) GetZoneContract(ctx context.Context, zone string) (*Contract, *Response, error)

GetZoneContract returns data about the Contract to which the Zone belongs.

Akamai API docs: https://developer.akamai.com/api/web_performance/fast_dns_zone_management/v2.html#getzonecontract

func (*FastDNSv2Service) GetZoneRecordSets

GetZoneRecordSets lists all record sets for this zone. Can only be used on PRIMARY and SECONDARY zones. This operation is paginated.

Akamai API docs: https://developer.akamai.com/api/web_performance/fast_dns_zone_management/v2.html#getzonerecordsets

func (*FastDNSv2Service) ListZones

func (s *FastDNSv2Service) ListZones(ctx context.Context, opt *ZoneListOptions) (*ZoneList, *Response, error)

ListZones retreives the zones for the authenticated user.

Akamai API docs: https://developer.akamai.com/api/web_performance/fast_dns_zone_management/v2.html#getzones

func (*FastDNSv2Service) SubmitChangeList

func (s *FastDNSv2Service) SubmitChangeList(ctx context.Context, zone string) (*Response, error)

SubmitChangeList applies all of the changes in this change list to the current zone. This operation fails if the change list has become stale.

Akamai API docs: https://developer.akamai.com/api/web_performance/fast_dns_zone_management/v2.html#postchangelistsubmit

func (*FastDNSv2Service) UpdateRecordSet

func (s *FastDNSv2Service) UpdateRecordSet(ctx context.Context, rs *RecordSetCreateRequest) (*RecordSet, *Response, error)

UpdateRecordSet replaces an existing Record Set with the request body. The name and type must match the existing record.

Akamai API docs: https://developer.akamai.com/api/web_performance/fast_dns_zone_management/v2.html#putzonerecordset

func (*FastDNSv2Service) UpdateZone

func (s *FastDNSv2Service) UpdateZone(ctx context.Context, zone *ZoneCreateRequest) (*Zone, *Response, error)

UpdateZone modifies an Akamai zone.

Akamai API docs: https://developer.akamai.com/api/web_performance/fast_dns_zone_management/v2.html#putzone

type ListZoneRecordMetadata

type ListZoneRecordMetadata struct {
	Zone          *string   `json:"zone,omitempty"`
	Types         []*string `json:"types,omitempty"`
	Page          *int      `json:"page,omitempty"`
	PageSize      *int      `json:"pageSize,omitempty"`
	TotalElements *int      `json:"totalElements,omitempty"`
}

ListZoneRecordMetadata holds the metadata response from GetZoneRecordSets.

type ListZoneRecordSetOptions

type ListZoneRecordSetOptions struct {
	Page     int    `url:"page,omitempty"`
	PageSize int    `url:"pageSize,omitempty"`
	Search   string `url:"search,omitempty"`
	ShowAll  bool   `url:"showAll,omitempty"`
	SortBy   string `url:"sortBy,omitempty"`
	Types    string `url:"types,omitempty"`
}

ListZoneRecordSetOptions are optional query parameters.

type ListZoneRecordSets

type ListZoneRecordSets struct {
	Metadata   *ListZoneRecordMetadata `json:"metadata,omitempty"`
	RecordSets []*RecordSet            `json:"recordsets,omitempty"`
}

ListZoneRecordSets holds the response from GetZoneRecordSets.

type RecordSet

type RecordSet struct {
	Name  *string   `json:"name,omitempty"`
	Rdata []*string `json:"rdata,omitempty"`
	TTL   *int      `json:"ttl,omitempty"`
	Type  *string   `json:"type,omitempty"`
	State *string   `json:"state,omitempty"`
}

RecordSet is set of DNS records belonging to a particular DNS name

type RecordSetCreateRequest

type RecordSetCreateRequest struct {
	Zone  string   `json:"zone,omitempty"`
	Name  string   `json:"name,omitempty"`
	Rdata []string `json:"rdata,omitempty"`
	TTL   int      `json:"ttl,omitempty"`
	Type  string   `json:"type,omitempty"`
}

RecordSetCreatRequest is a set of DNS records belonging to a particular DNS name to be created.

type RecordSetOptions

type RecordSetOptions struct {
	Zone string `json:"zone,omitempty"`
	Name string `json:"name,omitempty"`
	Type string `json:"type,omitempty"`
}

RecordSetOptions specifies optional parameters to some record set methods.

type Response

type Response struct {
	*http.Response
}

Response is an Akamai API response. It wraps http.Response and allows for us to add additional properties in the future.

type Signer

type Signer struct {
	Credentials *credentials.Credentials
	// HeadersToSign is a config option of Akamai Edgegrid. User must specify
	// the headers that Signer is meant to sign.
	HeadersToSign []string
	MaxBody       int

	// For testing we need to pass a fake nonce and timestamp
	// This is a bad strategy, but the signature relies upon it
	Timestamp string
	Nonce     string
}

Signer applies Akamai Edgegrid signing to a given request.

func NewSigner

func NewSigner(credentials *credentials.Credentials) *Signer

NewSigner returns a Signer pointer configured with the credentials

func (*Signer) Sign

func (s *Signer) Sign(req *http.Request, body io.ReadWriter) (http.Header, error)

Sign signs Akamai requests with the provided body.

type Zone

type Zone struct {
	ContractID         *string   `json:"contractId,omitempty"`
	Zone               *string   `json:"zone,omitempty"`
	Type               *string   `json:"type,omitempty"`
	Comment            *string   `json:"comment,omitempty"`
	EndCustomerID      *string   `json:"endCustomerId,omitempty"`
	Target             *string   `json:"target,omitempty"`
	TSIGKey            *tsigKey  `json:"tsigKey,omitempty"`
	Masters            []*string `json:"masters,omitempty"`
	VersionID          *string   `json:"versionId,omitempty"`
	LastModifiedDate   *string   `json:"lastModifiedDate,omitempty"`
	LastModifiedBy     *string   `json:"lastModifiedBy,omitempty"`
	LastActivationDate *string   `json:"lastActivationDate,omitempty"`
	ActivationState    *string   `json:"activationState,omitempty"`
}

Zone represents an Akamai zone from the v2 FastDNS API.

type ZoneCreateOptions

type ZoneCreateOptions struct {
	ContractID string `url:"contractId,omitempty"`
}

ZoneCreateOptions specifies the optional parameters to the FastDNSV2Service.CreateZone method.

type ZoneCreateRequest

type ZoneCreateRequest struct {
	Zone             string   `json:"zone,omitempty"`
	Type             string   `json:"type,omitempty"`
	Comment          string   `json:"comment,omitempty"`
	EndCustomerID    string   `json:"endCustomerId,omitempty"`
	Target           string   `json:"target,omitempty"`
	TSIGKey          string   `json:"tsigKey,omitempty"`
	Masters          []string `json:"masters,omitempty"`
	SignAndServe     bool     `json:"signAndServe"`
	SignAndServeAlgo string   `json:"signAndServeAlgorithm,omitempty"`
}

ZoneCreateRequest specifies the parameters for the CreateZone method.

type ZoneDeleteOptions

type ZoneDeleteOptions struct {
	Force bool `url:"force,omitempty"`
}

type ZoneDeleteRequest

type ZoneDeleteRequest struct {
	Zones []string `json:"zones,omitempty"`
}

ZoneDeleteRequest is a slice of zones to delete when making a request to the Akamai API.

type ZoneDeleteResponse

type ZoneDeleteResponse struct {
	RequestID      *string `json:"requestId,omitempty"`
	ExpirationDate *string `json:"expirationDate,omitempty"`
	ZonesSubmitted *int    `json:"zonesSubmitted,omitempty"`
	SuccessCount   *int    `json:"successCount,omitempty"`
	FailureCount   *int    `json:"failureCount,omitempty"`
	IsComplete     *bool   `json:"isComplete"`
}

ZoneDeleteResponse holds the response we must poll to confirm request success/failure.

type ZoneDeleteResult

type ZoneDeleteResult struct {
	RequestID    *string   `json:"requestId,omitempty"`
	DeletedZones []*string `json:"successfullyDeletedZones,omitempty"`
	FailedZones  []*struct {
		Zone          *string `json:"zone,omitempty"`
		FailureReason *string `json:"failiureReason,omitempty"`
	} `json:"failedZones,omitempty"`
}

ZoneDeleteResult holds the result of the ZoneDelete request

type ZoneList

type ZoneList struct {
	Metadata *ZoneListMetadata `json:"metadata,omitempty"`
	Zones    []*Zone           `json:"zones,omitempty"`
}

ZoneList holds a response from ListZones

type ZoneListMetadata

type ZoneListMetadata struct {
	ContractIDs   []*string `json:"contractId,omitempty"`
	Page          *int      `json:"page,omitempty"`
	PageSize      *int      `json:"pageSize,omitempty"`
	ShowAll       *bool     `json:"showAll,omitempty"`
	TotalElements *int      `json:"totalElements,omitempty"`
}

ZoneListMetadata holds metadata from the ZoneList response

type ZoneListOptions

type ZoneListOptions struct {
	ContractIDs string `url:"contractIds,omitempty"`
	Page        int    `url:"page,omitempty"`
	PageSize    int    `url:"pageSize,omitempty"`
	Search      string `url:"search,omitempty"`
	ShowAll     bool   `url:"showAll,omitempty"`
	SortBy      string `url:"sortBy,omitempty"`
	Types       string `url:"types,omitempty"`
	GroupID     int    `url:"gid,omitempty"`
}

ZoneListOptions specifies optional parameters to the FastDNSv2Service.ListZones method.

type ZoneMetadata

type ZoneMetadata struct {
	ContractID            *string `json:"contractId,omitempty"`
	Zone                  *string `json:"zone,omitempty"`
	Type                  *string `json:"type,omitempty"`
	AliasCount            *int    `json:"aliasCount,omitempty"`
	SignAndServe          *bool   `json:"signAndServe,omitempty"`
	SignAndServeAlgorithm *string `json:"signAndServeAlgorithm,omitempty"`
	VersionId             *string `json:"versionId,omitempty"`
	LastModifiedDate      *string `json:"lastModifiedDate,omitempty"`
	LastModifiedBy        *string `json:"lastModifiedBy,omitempty"`
	LastActivationDate    *string `json:"lastActivationDate,omitempty"`
	ActivationState       *string `json:"activationState,omitempty"`
	Comment               *string `json:"comment,omitempty"`
}

ZoneMetadata holds the response from GetZone

Directories

Path Synopsis
Package credentials supplies credentials to authenticate requests to the Akamai API.
Package credentials supplies credentials to authenticate requests to the Akamai API.

Jump to

Keyboard shortcuts

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