diff --git a/api.md b/api.md index 876aa42aff..ee2c69984b 100644 --- a/api.md +++ b/api.md @@ -60,15 +60,15 @@ Methods: - client.Zones.Settings.List(ctx context.Context, zoneIdentifier string) (cloudflare.ZoneSettingListResponse, error) - client.Zones.Settings.Edit(ctx context.Context, zoneIdentifier string, body cloudflare.ZoneSettingEditParams) (cloudflare.ZoneSettingEditResponse, error) -### AdvancedDdos +### AdvancedDDOS Response Types: -- cloudflare.ZoneSettingAdvancedDdoListResponse +- cloudflare.ZoneSettingAdvancedDDOSListResponse Methods: -- client.Zones.Settings.AdvancedDdos.List(ctx context.Context, zoneIdentifier string) (cloudflare.ZoneSettingAdvancedDdoListResponse, error) +- client.Zones.Settings.AdvancedDDOS.List(ctx context.Context, zoneIdentifier string) (cloudflare.ZoneSettingAdvancedDDOSListResponse, error) ### AlwaysOnlines diff --git a/zonesetting.go b/zonesetting.go index b3770f187d..dd606d92ae 100644 --- a/zonesetting.go +++ b/zonesetting.go @@ -20,7 +20,7 @@ import ( // instead. type ZoneSettingService struct { Options []option.RequestOption - AdvancedDdos *ZoneSettingAdvancedDdoService + AdvancedDDOS *ZoneSettingAdvancedDDOSService AlwaysOnlines *ZoneSettingAlwaysOnlineService AlwaysUseHTTPs *ZoneSettingAlwaysUseHTTPService AutomaticHTTPsRewrites *ZoneSettingAutomaticHTTPsRewriteService @@ -78,7 +78,7 @@ type ZoneSettingService struct { func NewZoneSettingService(opts ...option.RequestOption) (r *ZoneSettingService) { r = &ZoneSettingService{} r.Options = opts - r.AdvancedDdos = NewZoneSettingAdvancedDdoService(opts...) + r.AdvancedDDOS = NewZoneSettingAdvancedDDOSService(opts...) r.AlwaysOnlines = NewZoneSettingAlwaysOnlineService(opts...) r.AlwaysUseHTTPs = NewZoneSettingAlwaysUseHTTPService(opts...) r.AutomaticHTTPsRewrites = NewZoneSettingAutomaticHTTPsRewriteService(opts...) diff --git a/zonesettingadvancedddo.go b/zonesettingadvancedddo.go deleted file mode 100644 index 622087f3ef..0000000000 --- a/zonesettingadvancedddo.go +++ /dev/null @@ -1,156 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-sdk-go/internal/apijson" - "github.com/cloudflare/cloudflare-sdk-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-sdk-go/option" -) - -// ZoneSettingAdvancedDdoService contains methods and other services that help with -// interacting with the cloudflare API. Note, unlike clients, this service does not -// read variables from the environment automatically. You should not instantiate -// this service directly, and instead use the [NewZoneSettingAdvancedDdoService] -// method instead. -type ZoneSettingAdvancedDdoService struct { - Options []option.RequestOption -} - -// NewZoneSettingAdvancedDdoService generates a new service that applies the given -// options to each request. These options are applied after the parent client's -// options (if there is one), and before any request-specific options. -func NewZoneSettingAdvancedDdoService(opts ...option.RequestOption) (r *ZoneSettingAdvancedDdoService) { - r = &ZoneSettingAdvancedDdoService{} - r.Options = opts - return -} - -// Advanced protection from Distributed Denial of Service (DDoS) attacks on your -// website. This is an uneditable value that is 'on' in the case of Business and -// Enterprise zones. -func (r *ZoneSettingAdvancedDdoService) List(ctx context.Context, zoneIdentifier string, opts ...option.RequestOption) (res *ZoneSettingAdvancedDdoListResponse, err error) { - opts = append(r.Options[:], opts...) - path := fmt.Sprintf("zones/%s/settings/advanced_ddos", zoneIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) - return -} - -type ZoneSettingAdvancedDdoListResponse struct { - Errors []ZoneSettingAdvancedDdoListResponseError `json:"errors,required"` - Messages []ZoneSettingAdvancedDdoListResponseMessage `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - Result ZoneSettingAdvancedDdoListResponseResult `json:"result"` - JSON zoneSettingAdvancedDdoListResponseJSON `json:"-"` -} - -// zoneSettingAdvancedDdoListResponseJSON contains the JSON metadata for the struct -// [ZoneSettingAdvancedDdoListResponse] -type zoneSettingAdvancedDdoListResponseJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingAdvancedDdoListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -type ZoneSettingAdvancedDdoListResponseError struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingAdvancedDdoListResponseErrorJSON `json:"-"` -} - -// zoneSettingAdvancedDdoListResponseErrorJSON contains the JSON metadata for the -// struct [ZoneSettingAdvancedDdoListResponseError] -type zoneSettingAdvancedDdoListResponseErrorJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingAdvancedDdoListResponseError) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -type ZoneSettingAdvancedDdoListResponseMessage struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingAdvancedDdoListResponseMessageJSON `json:"-"` -} - -// zoneSettingAdvancedDdoListResponseMessageJSON contains the JSON metadata for the -// struct [ZoneSettingAdvancedDdoListResponseMessage] -type zoneSettingAdvancedDdoListResponseMessageJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingAdvancedDdoListResponseMessage) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -type ZoneSettingAdvancedDdoListResponseResult struct { - // ID of the zone setting. - ID ZoneSettingAdvancedDdoListResponseResultID `json:"id,required"` - // Value of the zone setting. Notes: Defaults to on for Business+ plans - Value ZoneSettingAdvancedDdoListResponseResultValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingAdvancedDdoListResponseResultEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingAdvancedDdoListResponseResultJSON `json:"-"` -} - -// zoneSettingAdvancedDdoListResponseResultJSON contains the JSON metadata for the -// struct [ZoneSettingAdvancedDdoListResponseResult] -type zoneSettingAdvancedDdoListResponseResultJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingAdvancedDdoListResponseResult) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -// ID of the zone setting. -type ZoneSettingAdvancedDdoListResponseResultID string - -const ( - ZoneSettingAdvancedDdoListResponseResultIDAdvancedDdos ZoneSettingAdvancedDdoListResponseResultID = "advanced_ddos" -) - -// Value of the zone setting. Notes: Defaults to on for Business+ plans -type ZoneSettingAdvancedDdoListResponseResultValue string - -const ( - ZoneSettingAdvancedDdoListResponseResultValueOn ZoneSettingAdvancedDdoListResponseResultValue = "on" - ZoneSettingAdvancedDdoListResponseResultValueOff ZoneSettingAdvancedDdoListResponseResultValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingAdvancedDdoListResponseResultEditable bool - -const ( - ZoneSettingAdvancedDdoListResponseResultEditableTrue ZoneSettingAdvancedDdoListResponseResultEditable = true - ZoneSettingAdvancedDdoListResponseResultEditableFalse ZoneSettingAdvancedDdoListResponseResultEditable = false -) diff --git a/zonesettingadvancedddos.go b/zonesettingadvancedddos.go new file mode 100644 index 0000000000..017d8c547b --- /dev/null +++ b/zonesettingadvancedddos.go @@ -0,0 +1,156 @@ +// File generated from our OpenAPI spec by Stainless. + +package cloudflare + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-sdk-go/internal/apijson" + "github.com/cloudflare/cloudflare-sdk-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-sdk-go/option" +) + +// ZoneSettingAdvancedDDOSService contains methods and other services that help +// with interacting with the cloudflare API. Note, unlike clients, this service +// does not read variables from the environment automatically. You should not +// instantiate this service directly, and instead use the +// [NewZoneSettingAdvancedDDOSService] method instead. +type ZoneSettingAdvancedDDOSService struct { + Options []option.RequestOption +} + +// NewZoneSettingAdvancedDDOSService generates a new service that applies the given +// options to each request. These options are applied after the parent client's +// options (if there is one), and before any request-specific options. +func NewZoneSettingAdvancedDDOSService(opts ...option.RequestOption) (r *ZoneSettingAdvancedDDOSService) { + r = &ZoneSettingAdvancedDDOSService{} + r.Options = opts + return +} + +// Advanced protection from Distributed Denial of Service (DDoS) attacks on your +// website. This is an uneditable value that is 'on' in the case of Business and +// Enterprise zones. +func (r *ZoneSettingAdvancedDDOSService) List(ctx context.Context, zoneIdentifier string, opts ...option.RequestOption) (res *ZoneSettingAdvancedDDOSListResponse, err error) { + opts = append(r.Options[:], opts...) + path := fmt.Sprintf("zones/%s/settings/advanced_ddos", zoneIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) + return +} + +type ZoneSettingAdvancedDDOSListResponse struct { + Errors []ZoneSettingAdvancedDDOSListResponseError `json:"errors,required"` + Messages []ZoneSettingAdvancedDDOSListResponseMessage `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + Result ZoneSettingAdvancedDDOSListResponseResult `json:"result"` + JSON zoneSettingAdvancedDDOSListResponseJSON `json:"-"` +} + +// zoneSettingAdvancedDDOSListResponseJSON contains the JSON metadata for the +// struct [ZoneSettingAdvancedDDOSListResponse] +type zoneSettingAdvancedDDOSListResponseJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZoneSettingAdvancedDDOSListResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +type ZoneSettingAdvancedDDOSListResponseError struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON zoneSettingAdvancedDDOSListResponseErrorJSON `json:"-"` +} + +// zoneSettingAdvancedDDOSListResponseErrorJSON contains the JSON metadata for the +// struct [ZoneSettingAdvancedDDOSListResponseError] +type zoneSettingAdvancedDDOSListResponseErrorJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZoneSettingAdvancedDDOSListResponseError) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +type ZoneSettingAdvancedDDOSListResponseMessage struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON zoneSettingAdvancedDDOSListResponseMessageJSON `json:"-"` +} + +// zoneSettingAdvancedDDOSListResponseMessageJSON contains the JSON metadata for +// the struct [ZoneSettingAdvancedDDOSListResponseMessage] +type zoneSettingAdvancedDDOSListResponseMessageJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZoneSettingAdvancedDDOSListResponseMessage) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +type ZoneSettingAdvancedDDOSListResponseResult struct { + // ID of the zone setting. + ID ZoneSettingAdvancedDDOSListResponseResultID `json:"id,required"` + // Value of the zone setting. Notes: Defaults to on for Business+ plans + Value ZoneSettingAdvancedDDOSListResponseResultValue `json:"value,required"` + // Whether or not this setting can be modified for this zone (based on your + // Cloudflare plan level). + Editable ZoneSettingAdvancedDDOSListResponseResultEditable `json:"editable"` + // last time this setting was modified. + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON zoneSettingAdvancedDDOSListResponseResultJSON `json:"-"` +} + +// zoneSettingAdvancedDDOSListResponseResultJSON contains the JSON metadata for the +// struct [ZoneSettingAdvancedDDOSListResponseResult] +type zoneSettingAdvancedDDOSListResponseResultJSON struct { + ID apijson.Field + Value apijson.Field + Editable apijson.Field + ModifiedOn apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZoneSettingAdvancedDDOSListResponseResult) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +// ID of the zone setting. +type ZoneSettingAdvancedDDOSListResponseResultID string + +const ( + ZoneSettingAdvancedDDOSListResponseResultIDAdvancedDDOS ZoneSettingAdvancedDDOSListResponseResultID = "advanced_ddos" +) + +// Value of the zone setting. Notes: Defaults to on for Business+ plans +type ZoneSettingAdvancedDDOSListResponseResultValue string + +const ( + ZoneSettingAdvancedDDOSListResponseResultValueOn ZoneSettingAdvancedDDOSListResponseResultValue = "on" + ZoneSettingAdvancedDDOSListResponseResultValueOff ZoneSettingAdvancedDDOSListResponseResultValue = "off" +) + +// Whether or not this setting can be modified for this zone (based on your +// Cloudflare plan level). +type ZoneSettingAdvancedDDOSListResponseResultEditable bool + +const ( + ZoneSettingAdvancedDDOSListResponseResultEditableTrue ZoneSettingAdvancedDDOSListResponseResultEditable = true + ZoneSettingAdvancedDDOSListResponseResultEditableFalse ZoneSettingAdvancedDDOSListResponseResultEditable = false +) diff --git a/zonesettingadvancedddo_test.go b/zonesettingadvancedddos_test.go similarity index 88% rename from zonesettingadvancedddo_test.go rename to zonesettingadvancedddos_test.go index 5fc920084d..100f4662f6 100644 --- a/zonesettingadvancedddo_test.go +++ b/zonesettingadvancedddos_test.go @@ -13,7 +13,7 @@ import ( "github.com/cloudflare/cloudflare-sdk-go/option" ) -func TestZoneSettingAdvancedDdoList(t *testing.T) { +func TestZoneSettingAdvancedDDOSList(t *testing.T) { baseURL := "http://localhost:4010" if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { baseURL = envURL @@ -27,7 +27,7 @@ func TestZoneSettingAdvancedDdoList(t *testing.T) { option.WithEmail("dev@cloudflare.com"), option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) - _, err := client.Zones.Settings.AdvancedDdos.List(context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353") + _, err := client.Zones.Settings.AdvancedDDOS.List(context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353") if err != nil { var apierr *cloudflare.Error if errors.As(err, &apierr) {