Skip to content

Commit

Permalink
DXE-2965 Merge pull request #190 from akamai/release/v7.2.0
Browse files Browse the repository at this point in the history
DXE-2965 Release/v7.2.0
  • Loading branch information
dawiddzhafarov authored Aug 22, 2023
2 parents 1d2ddcf + cd6b242 commit 28af256
Show file tree
Hide file tree
Showing 32 changed files with 8,104 additions and 2 deletions.
42 changes: 41 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,45 @@
# EDGEGRID GOLANG RELEASE NOTES

## 7.2.0 (August 22, 2023)

#### FEATURES/ENHANCEMENTS:

* [IMPORTANT] Added CloudWrapper API support
* Capacities
* [ListCapacities](https://techdocs.akamai.com/cloud-wrapper/reference/get-capacity-inventory)
* Configurations
* [GetConfiguration](https://techdocs.akamai.com/cloud-wrapper/reference/get-configuration)
* [ListConfigurations](https://techdocs.akamai.com/cloud-wrapper/reference/get-configurations)
* [CreateConfiguration](https://techdocs.akamai.com/cloud-wrapper/reference/post-configuration)
* [UpdateConfiguration](https://techdocs.akamai.com/cloud-wrapper/reference/put-configuration)
* [ActivateConfiguration](https://techdocs.akamai.com/cloud-wrapper/reference/post-configuration-activations)
* Locations
* [ListLocations](https://techdocs.akamai.com/cloud-wrapper/reference/get-locations)
* MultiCDN
* [ListAuthKeys](https://techdocs.akamai.com/cloud-wrapper/reference/get-auth-keys)
* [ListCDNProviders](https://techdocs.akamai.com/cloud-wrapper/reference/get-providers)
* Properties
* [ListProperties](https://techdocs.akamai.com/cloud-wrapper/reference/get-properties)
* [ListOrigins](https://techdocs.akamai.com/cloud-wrapper/reference/get-origins)

* [IMPORTANT] Added Client Lists API Support
* ClientLists
* [GetClientLists](https://techdocs.akamai.com/client-lists/reference/get-lists)
* Support filter by name or type
* [GetClientList](https://techdocs.akamai.com/client-lists/reference/get-list)
* [UpdateClientList](https://techdocs.akamai.com/client-lists/reference/put-update-list)
* [UpdateClientListItems](https://techdocs.akamai.com/client-lists/reference/post-update-items)
* [CreateClientList](https://techdocs.akamai.com/client-lists/reference/post-create-list)
* [DeleteClientList](https://techdocs.akamai.com/client-lists/reference/delete-list)
* Activations
* [GetActivation](https://techdocs.akamai.com/client-lists/reference/get-retrieve-activation-status)
* [GetActivationStatus](https://techdocs.akamai.com/client-lists/reference/get-activation-status)
* [CreateActivation](https://techdocs.akamai.com/client-lists/reference/post-activate-list)

* APPSEC
* Added Bot Management API Support
* Custom Client Sequence - read and update

## 7.1.0 (July 25, 2023)

### FEATURES/ENHANCEMENTS:
Expand Down Expand Up @@ -31,7 +71,7 @@
* DataStream
* Updated `connectors` details in DataStream 2 API v2.
* Updated `GetProperties` and `GetDatasetFields` methods in DataStream 2 API v2.
* Updated `CreateStream`, `GetStream`, `UpdateStream`, `DeleteStream` and `ListStreams` methods in DataStream 2 API v2.
* Updated `CreateStream`, `GetStream`, `UpdateStream`, `DeleteStream` and `ListStreams` methods in DataStream 2 API v2.
* Updated `Activate`, `Deactivate`, `ActivationHistory` and `Stream` details in DataStream 2 API v2 and also changed their corresponding response objects.

### FEATURES/ENHANCEMENTS:
Expand Down
1 change: 1 addition & 0 deletions pkg/appsec/export_configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ type (
CustomDefinedBots []map[string]interface{} `json:"customDefinedBots,omitempty"`
CustomBotCategorySequence []string `json:"customBotCategorySequence,omitempty"`
CustomClients []map[string]interface{} `json:"customClients,omitempty"`
CustomClientSequence []string `json:"customClientSequence,omitempty"`
ResponseActions *ResponseActions `json:"responseActions,omitempty"`
AdvancedSettings *AdvancedSettings `json:"advancedSettings,omitempty"`
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5150,6 +5150,10 @@
}
}
],
"customClientSequence": [
"a7fe489d-0354-43bd-b81c-8cabbe850cdd",
"60374346-2d1d-444d-91c1-90373e3f804a"
],
"customDefinedBots": [
{
"botId": "50789280-ba99-4f8f-b4c6-ad9c1c69569a",
Expand Down
1 change: 1 addition & 0 deletions pkg/botman/botman.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type (
CustomBotCategoryAction
CustomBotCategorySequence
CustomClient
CustomClientSequence
CustomDefinedBot
CustomDenyAction
JavascriptInjection
Expand Down
121 changes: 121 additions & 0 deletions pkg/botman/custom_client_sequence.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
package botman

import (
"context"
"fmt"
"net/http"

"github.com/akamai/AkamaiOPEN-edgegrid-golang/v7/pkg/edgegriderr"
validation "github.com/go-ozzo/ozzo-validation/v4"
)

type (
// The CustomClientSequence interface supports retrieving and updating the custom client sequence for a configuration
CustomClientSequence interface {
// GetCustomClientSequence is used to retrieve the custom client sequence for a config version
// See https://techdocs.akamai.com/bot-manager/reference/get-custom-client-sequence
GetCustomClientSequence(ctx context.Context, params GetCustomClientSequenceRequest) (*CustomClientSequenceResponse, error)

// UpdateCustomClientSequence is used to update the existing custom client sequence for a config version
// See https://techdocs.akamai.com/bot-manager/reference/put-custom-client-sequence
UpdateCustomClientSequence(ctx context.Context, params UpdateCustomClientSequenceRequest) (*CustomClientSequenceResponse, error)
}

// GetCustomClientSequenceRequest is used to retrieve custom client sequence
GetCustomClientSequenceRequest struct {
ConfigID int64
Version int64
}

// UpdateCustomClientSequenceRequest is used to modify custom client sequence
UpdateCustomClientSequenceRequest struct {
ConfigID int64 `json:"-"`
Version int64 `json:"-"`
Sequence []string `json:"sequence"`
}

// CustomClientSequenceResponse is used to represent custom client sequence
CustomClientSequenceResponse struct {
Sequence []string `json:"sequence"`
Validation ValidationResponse `json:"validation"`
}
)

// Validate validates a GetCustomClientSequenceRequest.
func (v GetCustomClientSequenceRequest) Validate() error {
return edgegriderr.ParseValidationErrors(validation.Errors{
"ConfigID": validation.Validate(v.ConfigID, validation.Required),
"Version": validation.Validate(v.Version, validation.Required),
})
}

// Validate validates an UpdateCustomClientSequenceRequest.
func (v UpdateCustomClientSequenceRequest) Validate() error {
return edgegriderr.ParseValidationErrors(validation.Errors{
"ConfigID": validation.Validate(v.ConfigID, validation.Required),
"Version": validation.Validate(v.Version, validation.Required),
"Sequence": validation.Validate(v.Sequence, validation.Required),
})
}

func (b *botman) GetCustomClientSequence(ctx context.Context, params GetCustomClientSequenceRequest) (*CustomClientSequenceResponse, error) {
logger := b.Log(ctx)
logger.Debug("GetCustomClientSequence")

if err := params.Validate(); err != nil {
return nil, fmt.Errorf("%w: %s", ErrStructValidation, err.Error())
}

uri := fmt.Sprintf(
"/appsec/v1/configs/%d/versions/%d/custom-client-sequence",
params.ConfigID,
params.Version)

req, err := http.NewRequestWithContext(ctx, http.MethodGet, uri, nil)
if err != nil {
return nil, fmt.Errorf("failed to create GetCustomClientSequence request: %w", err)
}

var result CustomClientSequenceResponse
resp, err := b.Exec(req, &result)
if err != nil {
return nil, fmt.Errorf("GetCustomClientSequence request failed: %w", err)
}

if resp.StatusCode != http.StatusOK {
return nil, b.Error(resp)
}

return &result, nil
}

func (b *botman) UpdateCustomClientSequence(ctx context.Context, params UpdateCustomClientSequenceRequest) (*CustomClientSequenceResponse, error) {
logger := b.Log(ctx)
logger.Debug("UpdateCustomClientSequence")

if err := params.Validate(); err != nil {
return nil, fmt.Errorf("%w: %s", ErrStructValidation, err.Error())
}

uri := fmt.Sprintf(
"/appsec/v1/configs/%d/versions/%d/custom-client-sequence",
params.ConfigID,
params.Version)

req, err := http.NewRequestWithContext(ctx, http.MethodPut, uri, nil)
if err != nil {
return nil, fmt.Errorf("failed to create UpdateCustomClientSequence request: %w", err)
}

var result CustomClientSequenceResponse
resp, err := b.Exec(req, &result, params)
if err != nil {
return nil, fmt.Errorf("UpdateCustomClientSequence request failed: %w", err)
}

if resp.StatusCode != http.StatusOK {
return nil, b.Error(resp)
}

return &result, nil
}
Loading

0 comments on commit 28af256

Please sign in to comment.