-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #144 from akamai/release/v2.9.0
Release/v2.9.0 (Jan. 24, 2022)
- Loading branch information
Showing
23 changed files
with
5,555 additions
and
988 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,28 @@ | ||
module github.com/akamai/AkamaiOPEN-edgegrid-golang/v2 | ||
|
||
go 1.14 | ||
go 1.17 | ||
|
||
require ( | ||
github.com/apex/log v1.9.0 | ||
github.com/go-ozzo/ozzo-validation v3.6.0+incompatible | ||
github.com/go-ozzo/ozzo-validation/v4 v4.3.0 | ||
github.com/google/uuid v1.1.1 | ||
github.com/kr/text v0.2.0 // indirect | ||
github.com/mitchellh/go-homedir v1.1.0 | ||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect | ||
github.com/pkg/errors v0.9.1 // indirect | ||
github.com/smartystreets/goconvey v1.6.4 // indirect | ||
github.com/spf13/cast v1.3.1 | ||
github.com/stretchr/testify v1.6.1 | ||
github.com/tj/assert v0.0.3 | ||
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect | ||
gopkg.in/ini.v1 v1.51.1 | ||
) | ||
|
||
require ( | ||
github.com/asaskevich/govalidator v0.0.0-20200108200545-475eaeb16496 // indirect | ||
github.com/davecgh/go-spew v1.1.1 // indirect | ||
github.com/kr/text v0.2.0 // indirect | ||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect | ||
github.com/pkg/errors v0.9.1 // indirect | ||
github.com/pmezard/go-difflib v1.0.0 // indirect | ||
github.com/smartystreets/goconvey v1.6.4 // indirect | ||
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect | ||
gopkg.in/yaml.v3 v3.0.0-20200605160147-a5ece683394c // indirect | ||
) | ||
|
||
retract v2.8.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,190 @@ | ||
package appsec | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"net/http" | ||
|
||
validation "github.com/go-ozzo/ozzo-validation/v4" | ||
) | ||
|
||
type ( | ||
// The AdvancedSettingsEvasivePathMatch supports retrieving or modifying the Evasive Path Match setting. | ||
// | ||
// https://developer.akamai.com/api/cloud_security/application_security/v1.html | ||
AdvancedSettingsEvasivePathMatch interface { | ||
// GetAdvancedSettingsEvasivePathMatch retrieves the Evasive Path Match setting | ||
GetAdvancedSettingsEvasivePathMatch(ctx context.Context, params GetAdvancedSettingsEvasivePathMatchRequest) (*GetAdvancedSettingsEvasivePathMatchResponse, error) | ||
// UpdateAdvancedSettingsEvasivePathMatch modifies the Evasive Path Match setting | ||
UpdateAdvancedSettingsEvasivePathMatch(ctx context.Context, params UpdateAdvancedSettingsEvasivePathMatchRequest) (*UpdateAdvancedSettingsEvasivePathMatchResponse, error) | ||
// RemoveAdvancedSettingsEvasivePathMatch removes the Evasive Path Match setting | ||
RemoveAdvancedSettingsEvasivePathMatch(ctx context.Context, params RemoveAdvancedSettingsEvasivePathMatchRequest) (*RemoveAdvancedSettingsEvasivePathMatchResponse, error) | ||
} | ||
|
||
// GetAdvancedSettingsEvasivePathMatchRequest is used to retrieve the EvasivePathMatch setting | ||
GetAdvancedSettingsEvasivePathMatchRequest struct { | ||
ConfigID int `json:"-"` | ||
Version int `json:"-"` | ||
PolicyID string `json:"-"` | ||
} | ||
|
||
// GetAdvancedSettingsEvasivePathMatchResponse returns the EvasivePathMatch setting | ||
GetAdvancedSettingsEvasivePathMatchResponse struct { | ||
EnablePathMatch bool `json:"enablePathMatch"` | ||
} | ||
|
||
// UpdateAdvancedSettingsEvasivePathMatchRequest is used to update the EvasivePathMatch setting | ||
UpdateAdvancedSettingsEvasivePathMatchRequest struct { | ||
ConfigID int `json:"-"` | ||
Version int `json:"-"` | ||
PolicyID string `json:"-"` | ||
EnablePathMatch bool `json:"enablePathMatch"` | ||
} | ||
|
||
// UpdateAdvancedSettingsEvasivePathMatchResponse returns the result of updating the EvasivePathMatch setting | ||
UpdateAdvancedSettingsEvasivePathMatchResponse struct { | ||
EnablePathMatch bool `json:"enablePathMatch"` | ||
} | ||
|
||
// RemoveAdvancedSettingsEvasivePathMatchRequest is used to clear the EvasivePathMatch setting | ||
RemoveAdvancedSettingsEvasivePathMatchRequest struct { | ||
ConfigID int `json:"-"` | ||
Version int `json:"-"` | ||
PolicyID string `json:"-"` | ||
EnablePathMatch bool `json:"enablePathMatch"` | ||
} | ||
|
||
// RemoveAdvancedSettingsEvasivePathMatchResponse returns the result of clearing the EvasivePathMatch setting | ||
RemoveAdvancedSettingsEvasivePathMatchResponse struct { | ||
ConfigID int `json:"-"` | ||
Version int `json:"-"` | ||
PolicyID string `json:"-"` | ||
EnablePathMatch bool `json:"enablePathMatch"` | ||
} | ||
) | ||
|
||
// Validate validates GetAdvancedSettingssEvasivePathMatchRequest | ||
func (v GetAdvancedSettingsEvasivePathMatchRequest) Validate() error { | ||
return validation.Errors{ | ||
"ConfigID": validation.Validate(v.ConfigID, validation.Required), | ||
"Version": validation.Validate(v.Version, validation.Required), | ||
}.Filter() | ||
} | ||
|
||
// Validate validates UpdateAdvancedSettingsEvasivePathMatchRequest | ||
func (v UpdateAdvancedSettingsEvasivePathMatchRequest) Validate() error { | ||
return validation.Errors{ | ||
"ConfigID": validation.Validate(v.ConfigID, validation.Required), | ||
"Version": validation.Validate(v.Version, validation.Required), | ||
}.Filter() | ||
} | ||
|
||
// Validate validates UpdateAdvancedSettingsEvasivePathMatchRequest | ||
func (v RemoveAdvancedSettingsEvasivePathMatchRequest) Validate() error { | ||
return validation.Errors{ | ||
"ConfigID": validation.Validate(v.ConfigID, validation.Required), | ||
"Version": validation.Validate(v.Version, validation.Required), | ||
}.Filter() | ||
} | ||
|
||
func (p *appsec) GetAdvancedSettingsEvasivePathMatch(ctx context.Context, params GetAdvancedSettingsEvasivePathMatchRequest) (*GetAdvancedSettingsEvasivePathMatchResponse, error) { | ||
if err := params.Validate(); err != nil { | ||
return nil, fmt.Errorf("%w: %s", ErrStructValidation, err.Error()) | ||
} | ||
|
||
logger := p.Log(ctx) | ||
logger.Debug("GetAdvancedSettingsLoggings") | ||
|
||
var rval GetAdvancedSettingsEvasivePathMatchResponse | ||
var uri string | ||
|
||
if params.PolicyID != "" { | ||
uri = fmt.Sprintf( | ||
"/appsec/v1/configs/%d/versions/%d/security-policies/%s/advanced-settings/evasive-path-match", | ||
params.ConfigID, | ||
params.Version, | ||
params.PolicyID) | ||
} else { | ||
uri = fmt.Sprintf( | ||
"/appsec/v1/configs/%d/versions/%d/advanced-settings/evasive-path-match", | ||
params.ConfigID, | ||
params.Version) | ||
} | ||
|
||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, uri, nil) | ||
if err != nil { | ||
return nil, fmt.Errorf("failed to create getadvancedsettingsloggings request: %w", err) | ||
} | ||
|
||
resp, err := p.Exec(req, &rval) | ||
if err != nil { | ||
return nil, fmt.Errorf("getadvancedsettingsloggings request failed: %w", err) | ||
} | ||
|
||
if resp.StatusCode != http.StatusOK { | ||
return nil, p.Error(resp) | ||
} | ||
|
||
return &rval, nil | ||
} | ||
|
||
func (p *appsec) UpdateAdvancedSettingsEvasivePathMatch(ctx context.Context, params UpdateAdvancedSettingsEvasivePathMatchRequest) (*UpdateAdvancedSettingsEvasivePathMatchResponse, error) { | ||
if err := params.Validate(); err != nil { | ||
return nil, fmt.Errorf("%w: %s", ErrStructValidation, err.Error()) | ||
} | ||
|
||
logger := p.Log(ctx) | ||
logger.Debug("UpdateAdvancedSettingsLogging") | ||
|
||
var putURL string | ||
if params.PolicyID != "" { | ||
putURL = fmt.Sprintf( | ||
"/appsec/v1/configs/%d/versions/%d/security-policies/%s/advanced-settings/evasive-path-match", | ||
params.ConfigID, | ||
params.Version, | ||
params.PolicyID) | ||
} else { | ||
putURL = fmt.Sprintf( | ||
"/appsec/v1/configs/%d/versions/%d/advanced-settings/evasive-path-match", | ||
params.ConfigID, | ||
params.Version) | ||
} | ||
|
||
req, err := http.NewRequestWithContext(ctx, http.MethodPut, putURL, nil) | ||
if err != nil { | ||
return nil, fmt.Errorf("failed to create create AdvancedSettingsLoggingrequest: %w", err) | ||
} | ||
|
||
req.Header.Set("Content-Type", "application/json") | ||
var rval UpdateAdvancedSettingsEvasivePathMatchResponse | ||
resp, err := p.Exec(req, &rval, params) | ||
if err != nil { | ||
return nil, fmt.Errorf("create AdvancedSettingsLogging request failed: %w", err) | ||
} | ||
|
||
if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusCreated { | ||
return nil, p.Error(resp) | ||
} | ||
|
||
return &rval, nil | ||
} | ||
|
||
func (p *appsec) RemoveAdvancedSettingsEvasivePathMatch(ctx context.Context, params RemoveAdvancedSettingsEvasivePathMatchRequest) (*RemoveAdvancedSettingsEvasivePathMatchResponse, error) { | ||
request := UpdateAdvancedSettingsEvasivePathMatchRequest{ | ||
ConfigID: params.ConfigID, | ||
Version: params.Version, | ||
PolicyID: params.PolicyID, | ||
EnablePathMatch: false, | ||
} | ||
_, err := p.UpdateAdvancedSettingsEvasivePathMatch(ctx, request) | ||
if err != nil { | ||
return nil, fmt.Errorf("UpdateAdvancedSettingsEvasivePathMatch request failed: %w", err) | ||
} | ||
response := RemoveAdvancedSettingsEvasivePathMatchResponse{ | ||
ConfigID: params.ConfigID, | ||
Version: params.Version, | ||
PolicyID: params.PolicyID, | ||
EnablePathMatch: false, | ||
} | ||
return &response, nil | ||
} |
Oops, something went wrong.