Skip to content

Commit

Permalink
Merge pull request #1113 from jacobbednarz/add-error-handling-for-uns…
Browse files Browse the repository at this point in the history
…upported-dlp-profile

dlp: throw exception when trying to delete a non-custom DLP profile
  • Loading branch information
jacobbednarz committed Oct 19, 2022
2 parents 67a638f + db05094 commit f2630a8
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions dlp_profile.go
Expand Up @@ -137,16 +137,16 @@ func (api *API) GetDLPProfile(ctx context.Context, rc *ResourceContainer, profil
return dlpProfileResponse.Result, nil
}

// CreateDLPProfiles creates a set of custom DLP Profile.
// CreateDLPProfiles creates a set of DLP Profile.
//
// API reference: https://api.cloudflare.com/#dlp-profiles-create-custom-profiles
func (api *API) CreateDLPProfiles(ctx context.Context, rc *ResourceContainer, params CreateDLPProfilesParams) ([]DLPProfile, error) {
if rc.Identifier == "" {
return []DLPProfile{}, ErrMissingResourceIdentifier
}

if params.Type == "" {
params.Type = "custom"
if params.Type == "" || params.Type != "custom" {
return []DLPProfile{}, fmt.Errorf("unsupported DLP profile type: %q", params.Type)
}

uri := buildURI(fmt.Sprintf("/%s/%s/dlp/profiles/%s", rc.Level, rc.Identifier, params.Type), nil)
Expand All @@ -165,7 +165,7 @@ func (api *API) CreateDLPProfiles(ctx context.Context, rc *ResourceContainer, pa
return dLPCustomProfilesResponse.Result, nil
}

// DeleteDLPProfile deletes a DLP custom profile.
// DeleteDLPProfile deletes a DLP profile. Only custom profiles can be deleted.
//
// API reference: https://api.cloudflare.com/#dlp-profiles-delete-custom-profile
func (api *API) DeleteDLPProfile(ctx context.Context, rc *ResourceContainer, profileID string) error {
Expand Down

0 comments on commit f2630a8

Please sign in to comment.