Skip to content

Commit

Permalink
Merge pull request #13 in FEE/akamaiopen-edgegrid-golang from TFP-170…
Browse files Browse the repository at this point in the history
…-property-version to v2

* commit '527ad758763074aad208d1ad0ed1b8c62b14f0c1':
  [TFP-170] Add interface composition in PAPI
  [TFP-170] Add interface composition in PAPI
  [TFP-170] Add GetAvailableBehaviors and GetAvailableCriteria
  [TFP-170] Add GetLatestVersion
  [TFP-170] Add GET and POST for property versions
  • Loading branch information
rodriguise committed Sep 16, 2020
2 parents 4af2390 + 527ad75 commit 387f4a7
Show file tree
Hide file tree
Showing 9 changed files with 1,409 additions and 45 deletions.
2 changes: 1 addition & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ github.com/apex/log v1.9.0/go.mod h1:m82fZlWIuiWzWP04XCTXmnX0xRkYYbCdYn8jbJeLBEA
github.com/apex/logs v1.0.0/go.mod h1:XzxuLZ5myVHDy9SAmYpamKKRNApGj54PfYLcFrXqDwo=
github.com/aphistic/golf v0.0.0-20180712155816-02c07f170c5a/go.mod h1:3NqKYiepwy8kCu4PNA+aP7WUV72eXWJeP9/r3/K9aLE=
github.com/aphistic/sweet v0.2.0/go.mod h1:fWDlIh/isSE9n6EPsRmC0det+whmX6dJid3stzu0Xys=
github.com/asaskevich/govalidator v0.0.0-20200108200545-475eaeb16496 h1:zV3ejI06GQ59hwDQAvmK1qxOQGB3WuVTRoY0okPTAv0=
github.com/asaskevich/govalidator v0.0.0-20200108200545-475eaeb16496/go.mod h1:oGkLhpf+kjZl6xBf758TQhh5XrAeiJv/7FRz/2spLIg=
github.com/aws/aws-sdk-go v1.20.6/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
github.com/aybabtme/rgbterm v0.0.0-20170906152045-cc83f3b3ce59/go.mod h1:q/89r3U2H7sSsE2t6Kca0lfwTK8JdoNGS/yzM/4iH5I=
Expand All @@ -14,7 +15,6 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
github.com/go-ozzo/ozzo-validation v3.6.0+incompatible h1:msy24VGS42fKO9K1vLz82/GeYW1cILu7Nuuj1N3BBkE=
github.com/go-ozzo/ozzo-validation/v4 v4.2.2 h1:5uhbQAuRK6taB9orHJXA5GtOCuQbsHktskg8aWciC68=
github.com/go-ozzo/ozzo-validation/v4 v4.2.2/go.mod h1:2NKgrcHl3z6cJs+3Oo940FPRiTzuqKbvfrL2RxCj6Ew=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
Expand Down
16 changes: 16 additions & 0 deletions pkg/papi/activation.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,22 @@ import (
)

type (
// Activations contains operations available on Activation resource
// See: https://developer.akamai.com/api/core_features/property_manager/v1.html#propertyactivationsgroup
Activations interface {
// CreateActivation creates a new activation or deactivation request
// See: https://developer.akamai.com/api/core_features/property_manager/v1.html#postpropertyactivations
CreateActivation(context.Context, CreateActivationRequest) (*CreateActivationResponse, error)

// GetActivation gets details about an activation
// See: https://developer.akamai.com/api/core_features/property_manager/v1.html#getpropertyactivation
GetActivation(context.Context, GetActivationRequest) (*GetActivationResponse, error)

// CancelActivation allows for canceling an activation while it is still PENDING
// See: https://developer.akamai.com/api/core_features/property_manager/v1.html#deletepropertyactivation
CancelActivation(context.Context, CancelActivationRequest) (*CancelActivationResponse, error)
}

// ActivationFallbackInfo encapsulates information about fast fallback, which may allow you to fallback to a previous activation when
// POSTing an activation with useFastFallback enabled.
ActivationFallbackInfo struct {
Expand Down
8 changes: 8 additions & 0 deletions pkg/papi/contract.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ import (
)

type (
// Contracts contains operations available on Contract resource
// See: https://developer.akamai.com/api/core_features/property_manager/v1.html#contractsgroup
Contracts interface {
// GetContract provides a read-only list of contract names and identifiers
// See: https://developer.akamai.com/api/core_features/property_manager/v1.html#getcontracts
GetContracts(context.Context) (*GetContractsResponse, error)
}

// Contract represents a property contract resource
Contract struct {
ContractID string `json:"contractId"`
Expand Down
16 changes: 16 additions & 0 deletions pkg/papi/cpcode.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,22 @@ import (
)

type (
// CPCodes contains operations available on CPCode resource
// See: https://developer.akamai.com/api/core_features/property_manager/v1.html#cpcodesgroup
CPCodes interface {
// GetCPCodes lists all available CP codes
// See: https://developer.akamai.com/api/core_features/property_manager/v1.html#getcpcodes
GetCPCodes(context.Context, GetCPCodesRequest) (*GetCPCodesResponse, error)

// GetCPCode gets CP code with provided ID
// See: https://developer.akamai.com/api/core_features/property_manager/v1.html#getcpcode
GetCPCode(context.Context, GetCPCodeRequest) (*GetCPCodesResponse, error)

// CreateCPCode creates a new CP code
// See: https://developer.akamai.com/api/core_features/property_manager/v1.html#postcpcodes
CreateCPCode(context.Context, CreateCPCodeRequest) (*CreateCPCodeResponse, error)
}

// CPCode contains CP code resource data
CPCode struct {
ID string `json:"cpcodeId"`
Expand Down
16 changes: 16 additions & 0 deletions pkg/papi/edgehostname.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,22 @@ import (
)

type (
// EdgeHostnames contains operations available on EdgeHostnames resource
// See: https://developer.akamai.com/api/core_features/property_manager/v1.html#edgehostnamesgroup
EdgeHostnames interface {
// GetEdgeHostnames fetches a list of edge hostnames
// See: https://developer.akamai.com/api/core_features/property_manager/v1.html#getedgehostnames
GetEdgeHostnames(context.Context, GetEdgeHostnamesRequest) (*GetEdgeHostnamesResponse, error)

// GetEdgeHostname fetches edge hostname with given ID
// See: https://developer.akamai.com/api/core_features/property_manager/v1.html#getedgehostname
GetEdgeHostname(context.Context, GetEdgeHostnameRequest) (*GetEdgeHostnamesResponse, error)

// CreateEdgeHostname creates a new edge hostname
// See: https://developer.akamai.com/api/core_features/property_manager/v1.html#postedgehostnames
CreateEdgeHostname(context.Context, CreateEdgeHostnameRequest) (*CreateEdgeHostnameResponse, error)
}

// GetEdgeHostnamesRequest contains query params used for listing edge hostnames
GetEdgeHostnamesRequest struct {
ContractID string
Expand Down
8 changes: 8 additions & 0 deletions pkg/papi/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ import (
)

type (
// Groups contains operations available on Group resource
// See: https://developer.akamai.com/api/core_features/property_manager/v1.html#groupsgroup
Groups interface {
// GetGroups provides a read-only list of groups, which may contain properties.
// See: https://developer.akamai.com/api/core_features/property_manager/v1.html#getgroups
GetGroups(context.Context) (*GetGroupsResponse, error)
}

// Group represents a property group resource
Group struct {
GroupID string `json:"groupId"`
Expand Down
50 changes: 6 additions & 44 deletions pkg/papi/papi.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
package papi

import (
"context"
"errors"

"github.com/akamai/AkamaiOPEN-edgegrid-golang/v2/pkg/session"
Expand All @@ -16,49 +15,12 @@ var (
type (
// PAPI is the papi api interface
PAPI interface {
// GetGroups provides a read-only list of groups, which may contain properties.
// See: https://developer.akamai.com/api/core_features/property_manager/v1.html#getgroups
GetGroups(context.Context) (*GetGroupsResponse, error)

// GetContract provides a read-only list of contract names and identifiers
// See: https://developer.akamai.com/api/core_features/property_manager/v1.html#getcontracts
GetContracts(context.Context) (*GetContractsResponse, error)

// CreateActivation creates a new activation or deactivation request
// See: https://developer.akamai.com/api/core_features/property_manager/v1.html#postpropertyactivations
CreateActivation(context.Context, CreateActivationRequest) (*CreateActivationResponse, error)

// GetActivation gets details about an activation
// See: https://developer.akamai.com/api/core_features/property_manager/v1.html#getpropertyactivation
GetActivation(context.Context, GetActivationRequest) (*GetActivationResponse, error)

// CancelActivation allows for canceling an activation while it is still PENDING
// See: https://developer.akamai.com/api/core_features/property_manager/v1.html#deletepropertyactivation
CancelActivation(context.Context, CancelActivationRequest) (*CancelActivationResponse, error)

// GetCPCodes lists all available CP codes
// See: https://developer.akamai.com/api/core_features/property_manager/v1.html#getcpcodes
GetCPCodes(context.Context, GetCPCodesRequest) (*GetCPCodesResponse, error)

// GetCPCode gets CP code with provided ID
// See: https://developer.akamai.com/api/core_features/property_manager/v1.html#getcpcode
GetCPCode(context.Context, GetCPCodeRequest) (*GetCPCodesResponse, error)

// CreateCPCode creates a new CP code
// See: https://developer.akamai.com/api/core_features/property_manager/v1.html#postcpcodes
CreateCPCode(context.Context, CreateCPCodeRequest) (*CreateCPCodeResponse, error)

// GetEdgeHostnames fetches a list of edge hostnames
// See: https://developer.akamai.com/api/core_features/property_manager/v1.html#getedgehostnames
GetEdgeHostnames(context.Context, GetEdgeHostnamesRequest) (*GetEdgeHostnamesResponse, error)

// GetEdgeHostname fetches edge hostname with given ID
// See: https://developer.akamai.com/api/core_features/property_manager/v1.html#getedgehostname
GetEdgeHostname(context.Context, GetEdgeHostnameRequest) (*GetEdgeHostnamesResponse, error)

// CreateEdgeHostname creates a new edge hostname
// See: https://developer.akamai.com/api/core_features/property_manager/v1.html#postedgehostnames
CreateEdgeHostname(context.Context, CreateEdgeHostnameRequest) (*CreateEdgeHostnameResponse, error)
Groups
Contracts
Activations
CPCodes
PropertyVersions
EdgeHostnames
}

papi struct {
Expand Down
Loading

0 comments on commit 387f4a7

Please sign in to comment.