From d7fdabd8a47a954c87862e8959ab0a3d5c8f2070 Mon Sep 17 00:00:00 2001 From: stainless-bot Date: Thu, 8 Feb 2024 19:26:45 +0000 Subject: [PATCH] feat: OpenAPI spec update --- .stats.yml | 2 +- api.md | 48 ++ client.go | 2 + internal/shared/union.go | 5 + rule.go | 26 ++ rulelist.go | 554 +++++++++++++++++++++++ rulelist_test.go | 167 +++++++ rulelistbulkoperation.go | 119 +++++ rulelistbulkoperation_test.go | 44 ++ rulelistitem.go | 810 ++++++++++++++++++++++++++++++++++ rulelistitem_test.go | 277 ++++++++++++ 11 files changed, 2053 insertions(+), 1 deletion(-) create mode 100644 rule.go create mode 100644 rulelist.go create mode 100644 rulelist_test.go create mode 100644 rulelistbulkoperation.go create mode 100644 rulelistbulkoperation_test.go create mode 100644 rulelistitem.go create mode 100644 rulelistitem_test.go diff --git a/.stats.yml b/.stats.yml index c1a33e0e690..a9a7b646afb 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1 +1 @@ -configured_endpoints: 337 +configured_endpoints: 348 diff --git a/api.md b/api.md index 599682930fc..2f21e4bf790 100644 --- a/api.md +++ b/api.md @@ -648,6 +648,54 @@ Methods: - client.AccountMembers.AccountMembersAddMember(ctx context.Context, accountIdentifier interface{}, body cloudflare.AccountMemberAccountMembersAddMemberParams) (cloudflare.AccountMemberAccountMembersAddMemberResponse, error) - client.AccountMembers.AccountMembersListMembers(ctx context.Context, accountIdentifier interface{}, query cloudflare.AccountMemberAccountMembersListMembersParams) ([]cloudflare.AccountMemberAccountMembersListMembersResponse, error) +# Rules + +## Lists + +Response Types: + +- cloudflare.RuleListGetResponse +- cloudflare.RuleListUpdateResponse +- cloudflare.RuleListDeleteResponse +- cloudflare.RuleListListsNewAListResponse +- cloudflare.RuleListListsGetListsResponse + +Methods: + +- client.Rules.Lists.Get(ctx context.Context, accountID string, listID string) ([]cloudflare.RuleListGetResponse, error) +- client.Rules.Lists.Update(ctx context.Context, accountID string, listID string, body cloudflare.RuleListUpdateParams) ([]cloudflare.RuleListUpdateResponse, error) +- client.Rules.Lists.Delete(ctx context.Context, accountID string, listID string) (cloudflare.RuleListDeleteResponse, error) +- client.Rules.Lists.ListsNewAList(ctx context.Context, accountID string, body cloudflare.RuleListListsNewAListParams) ([]cloudflare.RuleListListsNewAListResponse, error) +- client.Rules.Lists.ListsGetLists(ctx context.Context, accountID string) ([]cloudflare.RuleListListsGetListsResponse, error) + +### BulkOperations + +Response Types: + +- cloudflare.RuleListBulkOperationGetResponse + +Methods: + +- client.Rules.Lists.BulkOperations.Get(ctx context.Context, accountIdentifier string, operationID string) ([]cloudflare.RuleListBulkOperationGetResponse, error) + +### Items + +Response Types: + +- cloudflare.RuleListItemGetResponse +- cloudflare.RuleListItemDeleteResponse +- cloudflare.RuleListItemListsNewListItemsResponse +- cloudflare.RuleListItemListsGetListItemsResponse +- cloudflare.RuleListItemListsUpdateAllListItemsResponse + +Methods: + +- client.Rules.Lists.Items.Get(ctx context.Context, accountIdentifier string, listID string, itemID string) (cloudflare.RuleListItemGetResponse, error) +- client.Rules.Lists.Items.Delete(ctx context.Context, accountID string, listID string, body cloudflare.RuleListItemDeleteParams) (cloudflare.RuleListItemDeleteResponse, error) +- client.Rules.Lists.Items.ListsNewListItems(ctx context.Context, accountID string, listID string, body cloudflare.RuleListItemListsNewListItemsParams) (cloudflare.RuleListItemListsNewListItemsResponse, error) +- client.Rules.Lists.Items.ListsGetListItems(ctx context.Context, accountID string, listID string, query cloudflare.RuleListItemListsGetListItemsParams) ([]cloudflare.RuleListItemListsGetListItemsResponse, error) +- client.Rules.Lists.Items.ListsUpdateAllListItems(ctx context.Context, accountID string, listID string, body cloudflare.RuleListItemListsUpdateAllListItemsParams) (cloudflare.RuleListItemListsUpdateAllListItemsResponse, error) + # Tunnels Response Types: diff --git a/client.go b/client.go index 2ab2b85152f..b03f9ba1055 100644 --- a/client.go +++ b/client.go @@ -21,6 +21,7 @@ type Client struct { DNSRecords *DNSRecordService Emails *EmailService AccountMembers *AccountMemberService + Rules *RuleService Tunnels *TunnelService D1 *D1Service Dex *DexService @@ -88,6 +89,7 @@ func NewClient(opts ...option.RequestOption) (r *Client) { r.DNSRecords = NewDNSRecordService(opts...) r.Emails = NewEmailService(opts...) r.AccountMembers = NewAccountMemberService(opts...) + r.Rules = NewRuleService(opts...) r.Tunnels = NewTunnelService(opts...) r.D1 = NewD1Service(opts...) r.Dex = NewDexService(opts...) diff --git a/internal/shared/union.go b/internal/shared/union.go index 0078344eeae..7be82997225 100644 --- a/internal/shared/union.go +++ b/internal/shared/union.go @@ -31,6 +31,7 @@ func (UnionString) ImplementsAccessKeyAccessKeyConfigurationGetTheAccessKeyConfi func (UnionString) ImplementsAccessKeyAccessKeyConfigurationUpdateTheAccessKeyConfigurationResponse() { } func (UnionString) ImplementsAccessKeyRotateAccessKeyConfigurationRotateAccessKeysResponse() {} +func (UnionString) ImplementsRuleListItemGetResponse() {} func (UnionString) ImplementsTunnelConnectionDeleteResponse() {} func (UnionString) ImplementsD1DatabaseDeleteResponse() {} func (UnionString) ImplementsStreamAudioTrackDeleteResponse() {} @@ -117,6 +118,10 @@ func (UnionBool) ImplementsZarazHistoryConfigGetResponseConfigToolsZarazCustomMa func (UnionBool) ImplementsZarazHistoryConfigGetResponseConfigToolsZarazCustomManagedComponentSetting() { } +type UnionInt int64 + +func (UnionInt) ImplementsRuleListItemGetResponse() {} + type UnionFloat float64 func (UnionFloat) ImplementsDNSRecordGetResponseDNSRecordsARecordTTL() {} diff --git a/rule.go b/rule.go new file mode 100644 index 00000000000..b51bd451b66 --- /dev/null +++ b/rule.go @@ -0,0 +1,26 @@ +// File generated from our OpenAPI spec by Stainless. + +package cloudflare + +import ( + "github.com/cloudflare/cloudflare-sdk-go/option" +) + +// RuleService 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 [NewRuleService] method instead. +type RuleService struct { + Options []option.RequestOption + Lists *RuleListService +} + +// NewRuleService 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 NewRuleService(opts ...option.RequestOption) (r *RuleService) { + r = &RuleService{} + r.Options = opts + r.Lists = NewRuleListService(opts...) + return +} diff --git a/rulelist.go b/rulelist.go new file mode 100644 index 00000000000..024a8fa55f4 --- /dev/null +++ b/rulelist.go @@ -0,0 +1,554 @@ +// File generated from our OpenAPI spec by Stainless. + +package cloudflare + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-sdk-go/internal/apijson" + "github.com/cloudflare/cloudflare-sdk-go/internal/param" + "github.com/cloudflare/cloudflare-sdk-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-sdk-go/option" +) + +// RuleListService 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 [NewRuleListService] method instead. +type RuleListService struct { + Options []option.RequestOption + BulkOperations *RuleListBulkOperationService + Items *RuleListItemService +} + +// NewRuleListService 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 NewRuleListService(opts ...option.RequestOption) (r *RuleListService) { + r = &RuleListService{} + r.Options = opts + r.BulkOperations = NewRuleListBulkOperationService(opts...) + r.Items = NewRuleListItemService(opts...) + return +} + +// Fetches the details of a list. +func (r *RuleListService) Get(ctx context.Context, accountID string, listID string, opts ...option.RequestOption) (res *[]RuleListGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env RuleListGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/rules/lists/%s", accountID, listID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Updates the description of a list. +func (r *RuleListService) Update(ctx context.Context, accountID string, listID string, body RuleListUpdateParams, opts ...option.RequestOption) (res *[]RuleListUpdateResponse, err error) { + opts = append(r.Options[:], opts...) + var env RuleListUpdateResponseEnvelope + path := fmt.Sprintf("accounts/%s/rules/lists/%s", accountID, listID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Deletes a specific list and all its items. +func (r *RuleListService) Delete(ctx context.Context, accountID string, listID string, opts ...option.RequestOption) (res *RuleListDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env RuleListDeleteResponseEnvelope + path := fmt.Sprintf("accounts/%s/rules/lists/%s", accountID, listID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Creates a new list of the specified type. +func (r *RuleListService) ListsNewAList(ctx context.Context, accountID string, body RuleListListsNewAListParams, opts ...option.RequestOption) (res *[]RuleListListsNewAListResponse, err error) { + opts = append(r.Options[:], opts...) + var env RuleListListsNewAListResponseEnvelope + path := fmt.Sprintf("accounts/%s/rules/lists", accountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetches all lists in the account. +func (r *RuleListService) ListsGetLists(ctx context.Context, accountID string, opts ...option.RequestOption) (res *[]RuleListListsGetListsResponse, err error) { + opts = append(r.Options[:], opts...) + var env RuleListListsGetListsResponseEnvelope + path := fmt.Sprintf("accounts/%s/rules/lists", accountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type RuleListGetResponse = interface{} + +type RuleListUpdateResponse = interface{} + +type RuleListDeleteResponse struct { + // The unique ID of the item in the List. + ID string `json:"id"` + JSON ruleListDeleteResponseJSON `json:"-"` +} + +// ruleListDeleteResponseJSON contains the JSON metadata for the struct +// [RuleListDeleteResponse] +type ruleListDeleteResponseJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleListDeleteResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +type RuleListListsNewAListResponse = interface{} + +type RuleListListsGetListsResponse struct { + // The unique ID of the list. + ID string `json:"id,required"` + // The RFC 3339 timestamp of when the list was created. + CreatedOn string `json:"created_on,required"` + // The type of the list. Each type supports specific list items (IP addresses, + // ASNs, hostnames or redirects). + Kind RuleListListsGetListsResponseKind `json:"kind,required"` + // The RFC 3339 timestamp of when the list was last modified. + ModifiedOn string `json:"modified_on,required"` + // An informative name for the list. Use this name in filter and rule expressions. + Name string `json:"name,required"` + // The number of items in the list. + NumItems float64 `json:"num_items,required"` + // An informative summary of the list. + Description string `json:"description"` + // The number of [filters](/operations/filters-list-filters) referencing the list. + NumReferencingFilters float64 `json:"num_referencing_filters"` + JSON ruleListListsGetListsResponseJSON `json:"-"` +} + +// ruleListListsGetListsResponseJSON contains the JSON metadata for the struct +// [RuleListListsGetListsResponse] +type ruleListListsGetListsResponseJSON struct { + ID apijson.Field + CreatedOn apijson.Field + Kind apijson.Field + ModifiedOn apijson.Field + Name apijson.Field + NumItems apijson.Field + Description apijson.Field + NumReferencingFilters apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleListListsGetListsResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +// The type of the list. Each type supports specific list items (IP addresses, +// ASNs, hostnames or redirects). +type RuleListListsGetListsResponseKind string + +const ( + RuleListListsGetListsResponseKindIP RuleListListsGetListsResponseKind = "ip" + RuleListListsGetListsResponseKindRedirect RuleListListsGetListsResponseKind = "redirect" + RuleListListsGetListsResponseKindHostname RuleListListsGetListsResponseKind = "hostname" + RuleListListsGetListsResponseKindAsn RuleListListsGetListsResponseKind = "asn" +) + +type RuleListGetResponseEnvelope struct { + Errors []RuleListGetResponseEnvelopeErrors `json:"errors,required"` + Messages []RuleListGetResponseEnvelopeMessages `json:"messages,required"` + Result []RuleListGetResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success RuleListGetResponseEnvelopeSuccess `json:"success,required"` + JSON ruleListGetResponseEnvelopeJSON `json:"-"` +} + +// ruleListGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [RuleListGetResponseEnvelope] +type ruleListGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleListGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +type RuleListGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ruleListGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// ruleListGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [RuleListGetResponseEnvelopeErrors] +type ruleListGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleListGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +type RuleListGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ruleListGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// ruleListGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [RuleListGetResponseEnvelopeMessages] +type ruleListGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleListGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +// Whether the API call was successful +type RuleListGetResponseEnvelopeSuccess bool + +const ( + RuleListGetResponseEnvelopeSuccessTrue RuleListGetResponseEnvelopeSuccess = true +) + +type RuleListUpdateParams struct { + // An informative summary of the list. + Description param.Field[string] `json:"description"` +} + +func (r RuleListUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type RuleListUpdateResponseEnvelope struct { + Errors []RuleListUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []RuleListUpdateResponseEnvelopeMessages `json:"messages,required"` + Result []RuleListUpdateResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success RuleListUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON ruleListUpdateResponseEnvelopeJSON `json:"-"` +} + +// ruleListUpdateResponseEnvelopeJSON contains the JSON metadata for the struct +// [RuleListUpdateResponseEnvelope] +type ruleListUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleListUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +type RuleListUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ruleListUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// ruleListUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [RuleListUpdateResponseEnvelopeErrors] +type ruleListUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleListUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +type RuleListUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ruleListUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// ruleListUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [RuleListUpdateResponseEnvelopeMessages] +type ruleListUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleListUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +// Whether the API call was successful +type RuleListUpdateResponseEnvelopeSuccess bool + +const ( + RuleListUpdateResponseEnvelopeSuccessTrue RuleListUpdateResponseEnvelopeSuccess = true +) + +type RuleListDeleteResponseEnvelope struct { + Errors []RuleListDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []RuleListDeleteResponseEnvelopeMessages `json:"messages,required"` + Result RuleListDeleteResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success RuleListDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON ruleListDeleteResponseEnvelopeJSON `json:"-"` +} + +// ruleListDeleteResponseEnvelopeJSON contains the JSON metadata for the struct +// [RuleListDeleteResponseEnvelope] +type ruleListDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleListDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +type RuleListDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ruleListDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// ruleListDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [RuleListDeleteResponseEnvelopeErrors] +type ruleListDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleListDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +type RuleListDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ruleListDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// ruleListDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [RuleListDeleteResponseEnvelopeMessages] +type ruleListDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleListDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +// Whether the API call was successful +type RuleListDeleteResponseEnvelopeSuccess bool + +const ( + RuleListDeleteResponseEnvelopeSuccessTrue RuleListDeleteResponseEnvelopeSuccess = true +) + +type RuleListListsNewAListParams struct { + // The type of the list. Each type supports specific list items (IP addresses, + // ASNs, hostnames or redirects). + Kind param.Field[RuleListListsNewAListParamsKind] `json:"kind,required"` + // An informative name for the list. Use this name in filter and rule expressions. + Name param.Field[string] `json:"name,required"` + // An informative summary of the list. + Description param.Field[string] `json:"description"` +} + +func (r RuleListListsNewAListParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The type of the list. Each type supports specific list items (IP addresses, +// ASNs, hostnames or redirects). +type RuleListListsNewAListParamsKind string + +const ( + RuleListListsNewAListParamsKindIP RuleListListsNewAListParamsKind = "ip" + RuleListListsNewAListParamsKindRedirect RuleListListsNewAListParamsKind = "redirect" + RuleListListsNewAListParamsKindHostname RuleListListsNewAListParamsKind = "hostname" + RuleListListsNewAListParamsKindAsn RuleListListsNewAListParamsKind = "asn" +) + +type RuleListListsNewAListResponseEnvelope struct { + Errors []RuleListListsNewAListResponseEnvelopeErrors `json:"errors,required"` + Messages []RuleListListsNewAListResponseEnvelopeMessages `json:"messages,required"` + Result []RuleListListsNewAListResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success RuleListListsNewAListResponseEnvelopeSuccess `json:"success,required"` + JSON ruleListListsNewAListResponseEnvelopeJSON `json:"-"` +} + +// ruleListListsNewAListResponseEnvelopeJSON contains the JSON metadata for the +// struct [RuleListListsNewAListResponseEnvelope] +type ruleListListsNewAListResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleListListsNewAListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +type RuleListListsNewAListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ruleListListsNewAListResponseEnvelopeErrorsJSON `json:"-"` +} + +// ruleListListsNewAListResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [RuleListListsNewAListResponseEnvelopeErrors] +type ruleListListsNewAListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleListListsNewAListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +type RuleListListsNewAListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ruleListListsNewAListResponseEnvelopeMessagesJSON `json:"-"` +} + +// ruleListListsNewAListResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [RuleListListsNewAListResponseEnvelopeMessages] +type ruleListListsNewAListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleListListsNewAListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +// Whether the API call was successful +type RuleListListsNewAListResponseEnvelopeSuccess bool + +const ( + RuleListListsNewAListResponseEnvelopeSuccessTrue RuleListListsNewAListResponseEnvelopeSuccess = true +) + +type RuleListListsGetListsResponseEnvelope struct { + Errors []RuleListListsGetListsResponseEnvelopeErrors `json:"errors,required"` + Messages []RuleListListsGetListsResponseEnvelopeMessages `json:"messages,required"` + Result []RuleListListsGetListsResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success RuleListListsGetListsResponseEnvelopeSuccess `json:"success,required"` + JSON ruleListListsGetListsResponseEnvelopeJSON `json:"-"` +} + +// ruleListListsGetListsResponseEnvelopeJSON contains the JSON metadata for the +// struct [RuleListListsGetListsResponseEnvelope] +type ruleListListsGetListsResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleListListsGetListsResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +type RuleListListsGetListsResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ruleListListsGetListsResponseEnvelopeErrorsJSON `json:"-"` +} + +// ruleListListsGetListsResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [RuleListListsGetListsResponseEnvelopeErrors] +type ruleListListsGetListsResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleListListsGetListsResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +type RuleListListsGetListsResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ruleListListsGetListsResponseEnvelopeMessagesJSON `json:"-"` +} + +// ruleListListsGetListsResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [RuleListListsGetListsResponseEnvelopeMessages] +type ruleListListsGetListsResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleListListsGetListsResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +// Whether the API call was successful +type RuleListListsGetListsResponseEnvelopeSuccess bool + +const ( + RuleListListsGetListsResponseEnvelopeSuccessTrue RuleListListsGetListsResponseEnvelopeSuccess = true +) diff --git a/rulelist_test.go b/rulelist_test.go new file mode 100644 index 00000000000..3141af1c5b0 --- /dev/null +++ b/rulelist_test.go @@ -0,0 +1,167 @@ +// File generated from our OpenAPI spec by Stainless. + +package cloudflare_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-sdk-go" + "github.com/cloudflare/cloudflare-sdk-go/internal/testutil" + "github.com/cloudflare/cloudflare-sdk-go/option" +) + +func TestRuleListGet(t *testing.T) { + t.Skip("skipped: tests are disabled for the time being") + baseURL := "http://localhost:4010" + if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { + baseURL = envURL + } + if !testutil.CheckTestServer(t, baseURL) { + return + } + client := cloudflare.NewClient( + option.WithBaseURL(baseURL), + option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), + option.WithAPIEmail("dev@cloudflare.com"), + option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), + option.WithUserServiceKey("My User Service Key"), + ) + _, err := client.Rules.Lists.Get( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "2c0fc9fa937b11eaa1b71c4d701ab86e", + ) + if err != nil { + var apierr *cloudflare.Error + if errors.As(err, &apierr) { + t.Log(string(apierr.DumpRequest(true))) + } + t.Fatalf("err should be nil: %s", err.Error()) + } +} + +func TestRuleListUpdateWithOptionalParams(t *testing.T) { + t.Skip("skipped: tests are disabled for the time being") + baseURL := "http://localhost:4010" + if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { + baseURL = envURL + } + if !testutil.CheckTestServer(t, baseURL) { + return + } + client := cloudflare.NewClient( + option.WithBaseURL(baseURL), + option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), + option.WithAPIEmail("dev@cloudflare.com"), + option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), + option.WithUserServiceKey("My User Service Key"), + ) + _, err := client.Rules.Lists.Update( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "2c0fc9fa937b11eaa1b71c4d701ab86e", + cloudflare.RuleListUpdateParams{ + Description: cloudflare.F("This is a note"), + }, + ) + if err != nil { + var apierr *cloudflare.Error + if errors.As(err, &apierr) { + t.Log(string(apierr.DumpRequest(true))) + } + t.Fatalf("err should be nil: %s", err.Error()) + } +} + +func TestRuleListDelete(t *testing.T) { + t.Skip("skipped: tests are disabled for the time being") + baseURL := "http://localhost:4010" + if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { + baseURL = envURL + } + if !testutil.CheckTestServer(t, baseURL) { + return + } + client := cloudflare.NewClient( + option.WithBaseURL(baseURL), + option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), + option.WithAPIEmail("dev@cloudflare.com"), + option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), + option.WithUserServiceKey("My User Service Key"), + ) + _, err := client.Rules.Lists.Delete( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "2c0fc9fa937b11eaa1b71c4d701ab86e", + ) + if err != nil { + var apierr *cloudflare.Error + if errors.As(err, &apierr) { + t.Log(string(apierr.DumpRequest(true))) + } + t.Fatalf("err should be nil: %s", err.Error()) + } +} + +func TestRuleListListsNewAListWithOptionalParams(t *testing.T) { + t.Skip("skipped: tests are disabled for the time being") + baseURL := "http://localhost:4010" + if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { + baseURL = envURL + } + if !testutil.CheckTestServer(t, baseURL) { + return + } + client := cloudflare.NewClient( + option.WithBaseURL(baseURL), + option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), + option.WithAPIEmail("dev@cloudflare.com"), + option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), + option.WithUserServiceKey("My User Service Key"), + ) + _, err := client.Rules.Lists.ListsNewAList( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + cloudflare.RuleListListsNewAListParams{ + Kind: cloudflare.F(cloudflare.RuleListListsNewAListParamsKindIP), + Name: cloudflare.F("list1"), + Description: cloudflare.F("This is a note"), + }, + ) + if err != nil { + var apierr *cloudflare.Error + if errors.As(err, &apierr) { + t.Log(string(apierr.DumpRequest(true))) + } + t.Fatalf("err should be nil: %s", err.Error()) + } +} + +func TestRuleListListsGetLists(t *testing.T) { + t.Skip("skipped: tests are disabled for the time being") + baseURL := "http://localhost:4010" + if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { + baseURL = envURL + } + if !testutil.CheckTestServer(t, baseURL) { + return + } + client := cloudflare.NewClient( + option.WithBaseURL(baseURL), + option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), + option.WithAPIEmail("dev@cloudflare.com"), + option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), + option.WithUserServiceKey("My User Service Key"), + ) + _, err := client.Rules.Lists.ListsGetLists(context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353") + if err != nil { + var apierr *cloudflare.Error + if errors.As(err, &apierr) { + t.Log(string(apierr.DumpRequest(true))) + } + t.Fatalf("err should be nil: %s", err.Error()) + } +} diff --git a/rulelistbulkoperation.go b/rulelistbulkoperation.go new file mode 100644 index 00000000000..9f944875e1e --- /dev/null +++ b/rulelistbulkoperation.go @@ -0,0 +1,119 @@ +// File generated from our OpenAPI spec by Stainless. + +package cloudflare + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-sdk-go/internal/apijson" + "github.com/cloudflare/cloudflare-sdk-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-sdk-go/option" +) + +// RuleListBulkOperationService 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 [NewRuleListBulkOperationService] +// method instead. +type RuleListBulkOperationService struct { + Options []option.RequestOption +} + +// NewRuleListBulkOperationService 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 NewRuleListBulkOperationService(opts ...option.RequestOption) (r *RuleListBulkOperationService) { + r = &RuleListBulkOperationService{} + r.Options = opts + return +} + +// Gets the current status of an asynchronous operation on a list. +// +// The `status` property can have one of the following values: `pending`, +// `running`, `completed`, or `failed`. If the status is `failed`, the `error` +// property will contain a message describing the error. +func (r *RuleListBulkOperationService) Get(ctx context.Context, accountIdentifier string, operationID string, opts ...option.RequestOption) (res *[]RuleListBulkOperationGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env RuleListBulkOperationGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/rules/lists/bulk_operations/%s", accountIdentifier, operationID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type RuleListBulkOperationGetResponse = interface{} + +type RuleListBulkOperationGetResponseEnvelope struct { + Errors []RuleListBulkOperationGetResponseEnvelopeErrors `json:"errors,required"` + Messages []RuleListBulkOperationGetResponseEnvelopeMessages `json:"messages,required"` + Result []RuleListBulkOperationGetResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success RuleListBulkOperationGetResponseEnvelopeSuccess `json:"success,required"` + JSON ruleListBulkOperationGetResponseEnvelopeJSON `json:"-"` +} + +// ruleListBulkOperationGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [RuleListBulkOperationGetResponseEnvelope] +type ruleListBulkOperationGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleListBulkOperationGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +type RuleListBulkOperationGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ruleListBulkOperationGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// ruleListBulkOperationGetResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [RuleListBulkOperationGetResponseEnvelopeErrors] +type ruleListBulkOperationGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleListBulkOperationGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +type RuleListBulkOperationGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ruleListBulkOperationGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// ruleListBulkOperationGetResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [RuleListBulkOperationGetResponseEnvelopeMessages] +type ruleListBulkOperationGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleListBulkOperationGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +// Whether the API call was successful +type RuleListBulkOperationGetResponseEnvelopeSuccess bool + +const ( + RuleListBulkOperationGetResponseEnvelopeSuccessTrue RuleListBulkOperationGetResponseEnvelopeSuccess = true +) diff --git a/rulelistbulkoperation_test.go b/rulelistbulkoperation_test.go new file mode 100644 index 00000000000..52a4b6a60cc --- /dev/null +++ b/rulelistbulkoperation_test.go @@ -0,0 +1,44 @@ +// File generated from our OpenAPI spec by Stainless. + +package cloudflare_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-sdk-go" + "github.com/cloudflare/cloudflare-sdk-go/internal/testutil" + "github.com/cloudflare/cloudflare-sdk-go/option" +) + +func TestRuleListBulkOperationGet(t *testing.T) { + t.Skip("skipped: tests are disabled for the time being") + baseURL := "http://localhost:4010" + if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { + baseURL = envURL + } + if !testutil.CheckTestServer(t, baseURL) { + return + } + client := cloudflare.NewClient( + option.WithBaseURL(baseURL), + option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), + option.WithAPIEmail("dev@cloudflare.com"), + option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), + option.WithUserServiceKey("My User Service Key"), + ) + _, err := client.Rules.Lists.BulkOperations.Get( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "4da8780eeb215e6cb7f48dd981c4ea02", + ) + if err != nil { + var apierr *cloudflare.Error + if errors.As(err, &apierr) { + t.Log(string(apierr.DumpRequest(true))) + } + t.Fatalf("err should be nil: %s", err.Error()) + } +} diff --git a/rulelistitem.go b/rulelistitem.go new file mode 100644 index 00000000000..128666144e7 --- /dev/null +++ b/rulelistitem.go @@ -0,0 +1,810 @@ +// File generated from our OpenAPI spec by Stainless. + +package cloudflare + +import ( + "context" + "fmt" + "net/http" + "net/url" + "reflect" + + "github.com/cloudflare/cloudflare-sdk-go/internal/apijson" + "github.com/cloudflare/cloudflare-sdk-go/internal/apiquery" + "github.com/cloudflare/cloudflare-sdk-go/internal/param" + "github.com/cloudflare/cloudflare-sdk-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-sdk-go/internal/shared" + "github.com/cloudflare/cloudflare-sdk-go/option" + "github.com/tidwall/gjson" +) + +// RuleListItemService 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 [NewRuleListItemService] method +// instead. +type RuleListItemService struct { + Options []option.RequestOption +} + +// NewRuleListItemService 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 NewRuleListItemService(opts ...option.RequestOption) (r *RuleListItemService) { + r = &RuleListItemService{} + r.Options = opts + return +} + +// Fetches a list item in the list. +func (r *RuleListItemService) Get(ctx context.Context, accountIdentifier string, listID string, itemID string, opts ...option.RequestOption) (res *RuleListItemGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env RuleListItemGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/rules/lists/%s/items/%s", accountIdentifier, listID, itemID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Removes one or more items from a list. +// +// This operation is asynchronous. To get current the operation status, invoke the +// [Get bulk operation status](/operations/lists-get-bulk-operation-status) +// endpoint with the returned `operation_id`. +func (r *RuleListItemService) Delete(ctx context.Context, accountID string, listID string, body RuleListItemDeleteParams, opts ...option.RequestOption) (res *RuleListItemDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env RuleListItemDeleteResponseEnvelope + path := fmt.Sprintf("accounts/%s/rules/lists/%s/items", accountID, listID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Appends new items to the list. +// +// This operation is asynchronous. To get current the operation status, invoke the +// [Get bulk operation status](/operations/lists-get-bulk-operation-status) +// endpoint with the returned `operation_id`. +func (r *RuleListItemService) ListsNewListItems(ctx context.Context, accountID string, listID string, body RuleListItemListsNewListItemsParams, opts ...option.RequestOption) (res *RuleListItemListsNewListItemsResponse, err error) { + opts = append(r.Options[:], opts...) + var env RuleListItemListsNewListItemsResponseEnvelope + path := fmt.Sprintf("accounts/%s/rules/lists/%s/items", accountID, listID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetches all the items in the list. +func (r *RuleListItemService) ListsGetListItems(ctx context.Context, accountID string, listID string, query RuleListItemListsGetListItemsParams, opts ...option.RequestOption) (res *[]RuleListItemListsGetListItemsResponse, err error) { + opts = append(r.Options[:], opts...) + var env RuleListItemListsGetListItemsResponseEnvelope + path := fmt.Sprintf("accounts/%s/rules/lists/%s/items", accountID, listID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Removes all existing items from the list and adds the provided items to the +// list. +// +// This operation is asynchronous. To get current the operation status, invoke the +// [Get bulk operation status](/operations/lists-get-bulk-operation-status) +// endpoint with the returned `operation_id`. +func (r *RuleListItemService) ListsUpdateAllListItems(ctx context.Context, accountID string, listID string, body RuleListItemListsUpdateAllListItemsParams, opts ...option.RequestOption) (res *RuleListItemListsUpdateAllListItemsResponse, err error) { + opts = append(r.Options[:], opts...) + var env RuleListItemListsUpdateAllListItemsResponseEnvelope + path := fmt.Sprintf("accounts/%s/rules/lists/%s/items", accountID, listID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// An IPv4 address, an IPv4 CIDR, or an IPv6 CIDR. IPv6 CIDRs are limited to a +// maximum of /64. +// +// Union satisfied by [shared.UnionString], +// [RuleListItemGetResponseListsItemRedirect], +// [RuleListItemGetResponseListsItemHostname] or [shared.UnionInt]. +type RuleListItemGetResponse interface { + ImplementsRuleListItemGetResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RuleListItemGetResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionInt(0)), + }, + ) +} + +// The definition of the redirect. +type RuleListItemGetResponseListsItemRedirect struct { + SourceURL string `json:"source_url,required"` + TargetURL string `json:"target_url,required"` + IncludeSubdomains bool `json:"include_subdomains"` + PreservePathSuffix bool `json:"preserve_path_suffix"` + PreserveQueryString bool `json:"preserve_query_string"` + StatusCode RuleListItemGetResponseListsItemRedirectStatusCode `json:"status_code"` + SubpathMatching bool `json:"subpath_matching"` + JSON ruleListItemGetResponseListsItemRedirectJSON `json:"-"` +} + +// ruleListItemGetResponseListsItemRedirectJSON contains the JSON metadata for the +// struct [RuleListItemGetResponseListsItemRedirect] +type ruleListItemGetResponseListsItemRedirectJSON struct { + SourceURL apijson.Field + TargetURL apijson.Field + IncludeSubdomains apijson.Field + PreservePathSuffix apijson.Field + PreserveQueryString apijson.Field + StatusCode apijson.Field + SubpathMatching apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleListItemGetResponseListsItemRedirect) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r RuleListItemGetResponseListsItemRedirect) ImplementsRuleListItemGetResponse() {} + +type RuleListItemGetResponseListsItemRedirectStatusCode int64 + +const ( + RuleListItemGetResponseListsItemRedirectStatusCode301 RuleListItemGetResponseListsItemRedirectStatusCode = 301 + RuleListItemGetResponseListsItemRedirectStatusCode302 RuleListItemGetResponseListsItemRedirectStatusCode = 302 + RuleListItemGetResponseListsItemRedirectStatusCode307 RuleListItemGetResponseListsItemRedirectStatusCode = 307 + RuleListItemGetResponseListsItemRedirectStatusCode308 RuleListItemGetResponseListsItemRedirectStatusCode = 308 +) + +// Valid characters for hostnames are ASCII(7) letters from a to z, the digits from +// 0 to 9, wildcards (\*), and the hyphen (-). +type RuleListItemGetResponseListsItemHostname struct { + URLHostname string `json:"url_hostname,required"` + JSON ruleListItemGetResponseListsItemHostnameJSON `json:"-"` +} + +// ruleListItemGetResponseListsItemHostnameJSON contains the JSON metadata for the +// struct [RuleListItemGetResponseListsItemHostname] +type ruleListItemGetResponseListsItemHostnameJSON struct { + URLHostname apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleListItemGetResponseListsItemHostname) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r RuleListItemGetResponseListsItemHostname) ImplementsRuleListItemGetResponse() {} + +type RuleListItemDeleteResponse struct { + // The unique operation ID of the asynchronous action. + OperationID string `json:"operation_id"` + JSON ruleListItemDeleteResponseJSON `json:"-"` +} + +// ruleListItemDeleteResponseJSON contains the JSON metadata for the struct +// [RuleListItemDeleteResponse] +type ruleListItemDeleteResponseJSON struct { + OperationID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleListItemDeleteResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +type RuleListItemListsNewListItemsResponse struct { + // The unique operation ID of the asynchronous action. + OperationID string `json:"operation_id"` + JSON ruleListItemListsNewListItemsResponseJSON `json:"-"` +} + +// ruleListItemListsNewListItemsResponseJSON contains the JSON metadata for the +// struct [RuleListItemListsNewListItemsResponse] +type ruleListItemListsNewListItemsResponseJSON struct { + OperationID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleListItemListsNewListItemsResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +type RuleListItemListsGetListItemsResponse = interface{} + +type RuleListItemListsUpdateAllListItemsResponse struct { + // The unique operation ID of the asynchronous action. + OperationID string `json:"operation_id"` + JSON ruleListItemListsUpdateAllListItemsResponseJSON `json:"-"` +} + +// ruleListItemListsUpdateAllListItemsResponseJSON contains the JSON metadata for +// the struct [RuleListItemListsUpdateAllListItemsResponse] +type ruleListItemListsUpdateAllListItemsResponseJSON struct { + OperationID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleListItemListsUpdateAllListItemsResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +type RuleListItemGetResponseEnvelope struct { + Errors []RuleListItemGetResponseEnvelopeErrors `json:"errors,required"` + Messages []RuleListItemGetResponseEnvelopeMessages `json:"messages,required"` + // An IPv4 address, an IPv4 CIDR, or an IPv6 CIDR. IPv6 CIDRs are limited to a + // maximum of /64. + Result RuleListItemGetResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success RuleListItemGetResponseEnvelopeSuccess `json:"success,required"` + JSON ruleListItemGetResponseEnvelopeJSON `json:"-"` +} + +// ruleListItemGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [RuleListItemGetResponseEnvelope] +type ruleListItemGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleListItemGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +type RuleListItemGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ruleListItemGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// ruleListItemGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [RuleListItemGetResponseEnvelopeErrors] +type ruleListItemGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleListItemGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +type RuleListItemGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ruleListItemGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// ruleListItemGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [RuleListItemGetResponseEnvelopeMessages] +type ruleListItemGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleListItemGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +// Whether the API call was successful +type RuleListItemGetResponseEnvelopeSuccess bool + +const ( + RuleListItemGetResponseEnvelopeSuccessTrue RuleListItemGetResponseEnvelopeSuccess = true +) + +type RuleListItemDeleteParams struct { + Items param.Field[[]RuleListItemDeleteParamsItem] `json:"items"` +} + +func (r RuleListItemDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type RuleListItemDeleteParamsItem struct { + // The unique ID of the item in the List. + ID param.Field[string] `json:"id"` +} + +func (r RuleListItemDeleteParamsItem) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type RuleListItemDeleteResponseEnvelope struct { + Errors []RuleListItemDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []RuleListItemDeleteResponseEnvelopeMessages `json:"messages,required"` + Result RuleListItemDeleteResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success RuleListItemDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON ruleListItemDeleteResponseEnvelopeJSON `json:"-"` +} + +// ruleListItemDeleteResponseEnvelopeJSON contains the JSON metadata for the struct +// [RuleListItemDeleteResponseEnvelope] +type ruleListItemDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleListItemDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +type RuleListItemDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ruleListItemDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// ruleListItemDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [RuleListItemDeleteResponseEnvelopeErrors] +type ruleListItemDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleListItemDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +type RuleListItemDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ruleListItemDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// ruleListItemDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [RuleListItemDeleteResponseEnvelopeMessages] +type ruleListItemDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleListItemDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +// Whether the API call was successful +type RuleListItemDeleteResponseEnvelopeSuccess bool + +const ( + RuleListItemDeleteResponseEnvelopeSuccessTrue RuleListItemDeleteResponseEnvelopeSuccess = true +) + +type RuleListItemListsNewListItemsParams struct { + Body param.Field[[]RuleListItemListsNewListItemsParamsBody] `json:"body,required"` +} + +func (r RuleListItemListsNewListItemsParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) +} + +type RuleListItemListsNewListItemsParamsBody struct { + // A non-negative 32 bit integer + Asn param.Field[int64] `json:"asn"` + // An informative summary of the list item. + Comment param.Field[string] `json:"comment"` + // Valid characters for hostnames are ASCII(7) letters from a to z, the digits from + // 0 to 9, wildcards (\*), and the hyphen (-). + Hostname param.Field[RuleListItemListsNewListItemsParamsBodyHostname] `json:"hostname"` + // An IPv4 address, an IPv4 CIDR, or an IPv6 CIDR. IPv6 CIDRs are limited to a + // maximum of /64. + IP param.Field[string] `json:"ip"` + // The definition of the redirect. + Redirect param.Field[RuleListItemListsNewListItemsParamsBodyRedirect] `json:"redirect"` +} + +func (r RuleListItemListsNewListItemsParamsBody) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Valid characters for hostnames are ASCII(7) letters from a to z, the digits from +// 0 to 9, wildcards (\*), and the hyphen (-). +type RuleListItemListsNewListItemsParamsBodyHostname struct { + URLHostname param.Field[string] `json:"url_hostname,required"` +} + +func (r RuleListItemListsNewListItemsParamsBodyHostname) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The definition of the redirect. +type RuleListItemListsNewListItemsParamsBodyRedirect struct { + SourceURL param.Field[string] `json:"source_url,required"` + TargetURL param.Field[string] `json:"target_url,required"` + IncludeSubdomains param.Field[bool] `json:"include_subdomains"` + PreservePathSuffix param.Field[bool] `json:"preserve_path_suffix"` + PreserveQueryString param.Field[bool] `json:"preserve_query_string"` + StatusCode param.Field[RuleListItemListsNewListItemsParamsBodyRedirectStatusCode] `json:"status_code"` + SubpathMatching param.Field[bool] `json:"subpath_matching"` +} + +func (r RuleListItemListsNewListItemsParamsBodyRedirect) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type RuleListItemListsNewListItemsParamsBodyRedirectStatusCode int64 + +const ( + RuleListItemListsNewListItemsParamsBodyRedirectStatusCode301 RuleListItemListsNewListItemsParamsBodyRedirectStatusCode = 301 + RuleListItemListsNewListItemsParamsBodyRedirectStatusCode302 RuleListItemListsNewListItemsParamsBodyRedirectStatusCode = 302 + RuleListItemListsNewListItemsParamsBodyRedirectStatusCode307 RuleListItemListsNewListItemsParamsBodyRedirectStatusCode = 307 + RuleListItemListsNewListItemsParamsBodyRedirectStatusCode308 RuleListItemListsNewListItemsParamsBodyRedirectStatusCode = 308 +) + +type RuleListItemListsNewListItemsResponseEnvelope struct { + Errors []RuleListItemListsNewListItemsResponseEnvelopeErrors `json:"errors,required"` + Messages []RuleListItemListsNewListItemsResponseEnvelopeMessages `json:"messages,required"` + Result RuleListItemListsNewListItemsResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success RuleListItemListsNewListItemsResponseEnvelopeSuccess `json:"success,required"` + JSON ruleListItemListsNewListItemsResponseEnvelopeJSON `json:"-"` +} + +// ruleListItemListsNewListItemsResponseEnvelopeJSON contains the JSON metadata for +// the struct [RuleListItemListsNewListItemsResponseEnvelope] +type ruleListItemListsNewListItemsResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleListItemListsNewListItemsResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +type RuleListItemListsNewListItemsResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ruleListItemListsNewListItemsResponseEnvelopeErrorsJSON `json:"-"` +} + +// ruleListItemListsNewListItemsResponseEnvelopeErrorsJSON contains the JSON +// metadata for the struct [RuleListItemListsNewListItemsResponseEnvelopeErrors] +type ruleListItemListsNewListItemsResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleListItemListsNewListItemsResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +type RuleListItemListsNewListItemsResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ruleListItemListsNewListItemsResponseEnvelopeMessagesJSON `json:"-"` +} + +// ruleListItemListsNewListItemsResponseEnvelopeMessagesJSON contains the JSON +// metadata for the struct [RuleListItemListsNewListItemsResponseEnvelopeMessages] +type ruleListItemListsNewListItemsResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleListItemListsNewListItemsResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +// Whether the API call was successful +type RuleListItemListsNewListItemsResponseEnvelopeSuccess bool + +const ( + RuleListItemListsNewListItemsResponseEnvelopeSuccessTrue RuleListItemListsNewListItemsResponseEnvelopeSuccess = true +) + +type RuleListItemListsGetListItemsParams struct { + // The pagination cursor. An opaque string token indicating the position from which + // to continue when requesting the next/previous set of records. Cursor values are + // provided under `result_info.cursors` in the response. You should make no + // assumptions about a cursor's content or length. + Cursor param.Field[string] `query:"cursor"` + // Amount of results to include in each paginated response. A non-negative 32 bit + // integer. + PerPage param.Field[int64] `query:"per_page"` + // A search query to filter returned items. Its meaning depends on the list type: + // IP addresses must start with the provided string, hostnames and bulk redirects + // must contain the string, and ASNs must match the string exactly. + Search param.Field[string] `query:"search"` +} + +// URLQuery serializes [RuleListItemListsGetListItemsParams]'s query parameters as +// `url.Values`. +func (r RuleListItemListsGetListItemsParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type RuleListItemListsGetListItemsResponseEnvelope struct { + Errors []RuleListItemListsGetListItemsResponseEnvelopeErrors `json:"errors,required"` + Messages []RuleListItemListsGetListItemsResponseEnvelopeMessages `json:"messages,required"` + Result []RuleListItemListsGetListItemsResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success RuleListItemListsGetListItemsResponseEnvelopeSuccess `json:"success,required"` + ResultInfo RuleListItemListsGetListItemsResponseEnvelopeResultInfo `json:"result_info"` + JSON ruleListItemListsGetListItemsResponseEnvelopeJSON `json:"-"` +} + +// ruleListItemListsGetListItemsResponseEnvelopeJSON contains the JSON metadata for +// the struct [RuleListItemListsGetListItemsResponseEnvelope] +type ruleListItemListsGetListItemsResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + ResultInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleListItemListsGetListItemsResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +type RuleListItemListsGetListItemsResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ruleListItemListsGetListItemsResponseEnvelopeErrorsJSON `json:"-"` +} + +// ruleListItemListsGetListItemsResponseEnvelopeErrorsJSON contains the JSON +// metadata for the struct [RuleListItemListsGetListItemsResponseEnvelopeErrors] +type ruleListItemListsGetListItemsResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleListItemListsGetListItemsResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +type RuleListItemListsGetListItemsResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ruleListItemListsGetListItemsResponseEnvelopeMessagesJSON `json:"-"` +} + +// ruleListItemListsGetListItemsResponseEnvelopeMessagesJSON contains the JSON +// metadata for the struct [RuleListItemListsGetListItemsResponseEnvelopeMessages] +type ruleListItemListsGetListItemsResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleListItemListsGetListItemsResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +// Whether the API call was successful +type RuleListItemListsGetListItemsResponseEnvelopeSuccess bool + +const ( + RuleListItemListsGetListItemsResponseEnvelopeSuccessTrue RuleListItemListsGetListItemsResponseEnvelopeSuccess = true +) + +type RuleListItemListsGetListItemsResponseEnvelopeResultInfo struct { + Cursors RuleListItemListsGetListItemsResponseEnvelopeResultInfoCursors `json:"cursors"` + JSON ruleListItemListsGetListItemsResponseEnvelopeResultInfoJSON `json:"-"` +} + +// ruleListItemListsGetListItemsResponseEnvelopeResultInfoJSON contains the JSON +// metadata for the struct +// [RuleListItemListsGetListItemsResponseEnvelopeResultInfo] +type ruleListItemListsGetListItemsResponseEnvelopeResultInfoJSON struct { + Cursors apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleListItemListsGetListItemsResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +type RuleListItemListsGetListItemsResponseEnvelopeResultInfoCursors struct { + After string `json:"after"` + Before string `json:"before"` + JSON ruleListItemListsGetListItemsResponseEnvelopeResultInfoCursorsJSON `json:"-"` +} + +// ruleListItemListsGetListItemsResponseEnvelopeResultInfoCursorsJSON contains the +// JSON metadata for the struct +// [RuleListItemListsGetListItemsResponseEnvelopeResultInfoCursors] +type ruleListItemListsGetListItemsResponseEnvelopeResultInfoCursorsJSON struct { + After apijson.Field + Before apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleListItemListsGetListItemsResponseEnvelopeResultInfoCursors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +type RuleListItemListsUpdateAllListItemsParams struct { + Body param.Field[[]RuleListItemListsUpdateAllListItemsParamsBody] `json:"body,required"` +} + +func (r RuleListItemListsUpdateAllListItemsParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) +} + +type RuleListItemListsUpdateAllListItemsParamsBody struct { + // A non-negative 32 bit integer + Asn param.Field[int64] `json:"asn"` + // An informative summary of the list item. + Comment param.Field[string] `json:"comment"` + // Valid characters for hostnames are ASCII(7) letters from a to z, the digits from + // 0 to 9, wildcards (\*), and the hyphen (-). + Hostname param.Field[RuleListItemListsUpdateAllListItemsParamsBodyHostname] `json:"hostname"` + // An IPv4 address, an IPv4 CIDR, or an IPv6 CIDR. IPv6 CIDRs are limited to a + // maximum of /64. + IP param.Field[string] `json:"ip"` + // The definition of the redirect. + Redirect param.Field[RuleListItemListsUpdateAllListItemsParamsBodyRedirect] `json:"redirect"` +} + +func (r RuleListItemListsUpdateAllListItemsParamsBody) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Valid characters for hostnames are ASCII(7) letters from a to z, the digits from +// 0 to 9, wildcards (\*), and the hyphen (-). +type RuleListItemListsUpdateAllListItemsParamsBodyHostname struct { + URLHostname param.Field[string] `json:"url_hostname,required"` +} + +func (r RuleListItemListsUpdateAllListItemsParamsBodyHostname) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The definition of the redirect. +type RuleListItemListsUpdateAllListItemsParamsBodyRedirect struct { + SourceURL param.Field[string] `json:"source_url,required"` + TargetURL param.Field[string] `json:"target_url,required"` + IncludeSubdomains param.Field[bool] `json:"include_subdomains"` + PreservePathSuffix param.Field[bool] `json:"preserve_path_suffix"` + PreserveQueryString param.Field[bool] `json:"preserve_query_string"` + StatusCode param.Field[RuleListItemListsUpdateAllListItemsParamsBodyRedirectStatusCode] `json:"status_code"` + SubpathMatching param.Field[bool] `json:"subpath_matching"` +} + +func (r RuleListItemListsUpdateAllListItemsParamsBodyRedirect) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type RuleListItemListsUpdateAllListItemsParamsBodyRedirectStatusCode int64 + +const ( + RuleListItemListsUpdateAllListItemsParamsBodyRedirectStatusCode301 RuleListItemListsUpdateAllListItemsParamsBodyRedirectStatusCode = 301 + RuleListItemListsUpdateAllListItemsParamsBodyRedirectStatusCode302 RuleListItemListsUpdateAllListItemsParamsBodyRedirectStatusCode = 302 + RuleListItemListsUpdateAllListItemsParamsBodyRedirectStatusCode307 RuleListItemListsUpdateAllListItemsParamsBodyRedirectStatusCode = 307 + RuleListItemListsUpdateAllListItemsParamsBodyRedirectStatusCode308 RuleListItemListsUpdateAllListItemsParamsBodyRedirectStatusCode = 308 +) + +type RuleListItemListsUpdateAllListItemsResponseEnvelope struct { + Errors []RuleListItemListsUpdateAllListItemsResponseEnvelopeErrors `json:"errors,required"` + Messages []RuleListItemListsUpdateAllListItemsResponseEnvelopeMessages `json:"messages,required"` + Result RuleListItemListsUpdateAllListItemsResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success RuleListItemListsUpdateAllListItemsResponseEnvelopeSuccess `json:"success,required"` + JSON ruleListItemListsUpdateAllListItemsResponseEnvelopeJSON `json:"-"` +} + +// ruleListItemListsUpdateAllListItemsResponseEnvelopeJSON contains the JSON +// metadata for the struct [RuleListItemListsUpdateAllListItemsResponseEnvelope] +type ruleListItemListsUpdateAllListItemsResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleListItemListsUpdateAllListItemsResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +type RuleListItemListsUpdateAllListItemsResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ruleListItemListsUpdateAllListItemsResponseEnvelopeErrorsJSON `json:"-"` +} + +// ruleListItemListsUpdateAllListItemsResponseEnvelopeErrorsJSON contains the JSON +// metadata for the struct +// [RuleListItemListsUpdateAllListItemsResponseEnvelopeErrors] +type ruleListItemListsUpdateAllListItemsResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleListItemListsUpdateAllListItemsResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +type RuleListItemListsUpdateAllListItemsResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ruleListItemListsUpdateAllListItemsResponseEnvelopeMessagesJSON `json:"-"` +} + +// ruleListItemListsUpdateAllListItemsResponseEnvelopeMessagesJSON contains the +// JSON metadata for the struct +// [RuleListItemListsUpdateAllListItemsResponseEnvelopeMessages] +type ruleListItemListsUpdateAllListItemsResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleListItemListsUpdateAllListItemsResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +// Whether the API call was successful +type RuleListItemListsUpdateAllListItemsResponseEnvelopeSuccess bool + +const ( + RuleListItemListsUpdateAllListItemsResponseEnvelopeSuccessTrue RuleListItemListsUpdateAllListItemsResponseEnvelopeSuccess = true +) diff --git a/rulelistitem_test.go b/rulelistitem_test.go new file mode 100644 index 00000000000..e8722a50781 --- /dev/null +++ b/rulelistitem_test.go @@ -0,0 +1,277 @@ +// File generated from our OpenAPI spec by Stainless. + +package cloudflare_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-sdk-go" + "github.com/cloudflare/cloudflare-sdk-go/internal/testutil" + "github.com/cloudflare/cloudflare-sdk-go/option" +) + +func TestRuleListItemGet(t *testing.T) { + t.Skip("skipped: tests are disabled for the time being") + baseURL := "http://localhost:4010" + if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { + baseURL = envURL + } + if !testutil.CheckTestServer(t, baseURL) { + return + } + client := cloudflare.NewClient( + option.WithBaseURL(baseURL), + option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), + option.WithAPIEmail("dev@cloudflare.com"), + option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), + option.WithUserServiceKey("My User Service Key"), + ) + _, err := client.Rules.Lists.Items.Get( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "2c0fc9fa937b11eaa1b71c4d701ab86e", + "34b12448945f11eaa1b71c4d701ab86e", + ) + if err != nil { + var apierr *cloudflare.Error + if errors.As(err, &apierr) { + t.Log(string(apierr.DumpRequest(true))) + } + t.Fatalf("err should be nil: %s", err.Error()) + } +} + +func TestRuleListItemDeleteWithOptionalParams(t *testing.T) { + t.Skip("skipped: tests are disabled for the time being") + baseURL := "http://localhost:4010" + if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { + baseURL = envURL + } + if !testutil.CheckTestServer(t, baseURL) { + return + } + client := cloudflare.NewClient( + option.WithBaseURL(baseURL), + option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), + option.WithAPIEmail("dev@cloudflare.com"), + option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), + option.WithUserServiceKey("My User Service Key"), + ) + _, err := client.Rules.Lists.Items.Delete( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "2c0fc9fa937b11eaa1b71c4d701ab86e", + cloudflare.RuleListItemDeleteParams{ + Items: cloudflare.F([]cloudflare.RuleListItemDeleteParamsItem{{ + ID: cloudflare.F("34b12448945f11eaa1b71c4d701ab86e"), + }}), + }, + ) + if err != nil { + var apierr *cloudflare.Error + if errors.As(err, &apierr) { + t.Log(string(apierr.DumpRequest(true))) + } + t.Fatalf("err should be nil: %s", err.Error()) + } +} + +func TestRuleListItemListsNewListItems(t *testing.T) { + t.Skip("skipped: tests are disabled for the time being") + baseURL := "http://localhost:4010" + if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { + baseURL = envURL + } + if !testutil.CheckTestServer(t, baseURL) { + return + } + client := cloudflare.NewClient( + option.WithBaseURL(baseURL), + option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), + option.WithAPIEmail("dev@cloudflare.com"), + option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), + option.WithUserServiceKey("My User Service Key"), + ) + _, err := client.Rules.Lists.Items.ListsNewListItems( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "2c0fc9fa937b11eaa1b71c4d701ab86e", + cloudflare.RuleListItemListsNewListItemsParams{ + Body: cloudflare.F([]cloudflare.RuleListItemListsNewListItemsParamsBody{{ + Asn: cloudflare.F(int64(5567)), + Comment: cloudflare.F("Private IP address"), + Hostname: cloudflare.F(cloudflare.RuleListItemListsNewListItemsParamsBodyHostname{ + URLHostname: cloudflare.F("example.com"), + }), + IP: cloudflare.F("10.0.0.1"), + Redirect: cloudflare.F(cloudflare.RuleListItemListsNewListItemsParamsBodyRedirect{ + IncludeSubdomains: cloudflare.F(true), + PreservePathSuffix: cloudflare.F(true), + PreserveQueryString: cloudflare.F(true), + SourceURL: cloudflare.F("example.com/arch"), + StatusCode: cloudflare.F(cloudflare.RuleListItemListsNewListItemsParamsBodyRedirectStatusCode301), + SubpathMatching: cloudflare.F(true), + TargetURL: cloudflare.F("https://archlinux.org/"), + }), + }, { + Asn: cloudflare.F(int64(5567)), + Comment: cloudflare.F("Private IP address"), + Hostname: cloudflare.F(cloudflare.RuleListItemListsNewListItemsParamsBodyHostname{ + URLHostname: cloudflare.F("example.com"), + }), + IP: cloudflare.F("10.0.0.1"), + Redirect: cloudflare.F(cloudflare.RuleListItemListsNewListItemsParamsBodyRedirect{ + IncludeSubdomains: cloudflare.F(true), + PreservePathSuffix: cloudflare.F(true), + PreserveQueryString: cloudflare.F(true), + SourceURL: cloudflare.F("example.com/arch"), + StatusCode: cloudflare.F(cloudflare.RuleListItemListsNewListItemsParamsBodyRedirectStatusCode301), + SubpathMatching: cloudflare.F(true), + TargetURL: cloudflare.F("https://archlinux.org/"), + }), + }, { + Asn: cloudflare.F(int64(5567)), + Comment: cloudflare.F("Private IP address"), + Hostname: cloudflare.F(cloudflare.RuleListItemListsNewListItemsParamsBodyHostname{ + URLHostname: cloudflare.F("example.com"), + }), + IP: cloudflare.F("10.0.0.1"), + Redirect: cloudflare.F(cloudflare.RuleListItemListsNewListItemsParamsBodyRedirect{ + IncludeSubdomains: cloudflare.F(true), + PreservePathSuffix: cloudflare.F(true), + PreserveQueryString: cloudflare.F(true), + SourceURL: cloudflare.F("example.com/arch"), + StatusCode: cloudflare.F(cloudflare.RuleListItemListsNewListItemsParamsBodyRedirectStatusCode301), + SubpathMatching: cloudflare.F(true), + TargetURL: cloudflare.F("https://archlinux.org/"), + }), + }}), + }, + ) + if err != nil { + var apierr *cloudflare.Error + if errors.As(err, &apierr) { + t.Log(string(apierr.DumpRequest(true))) + } + t.Fatalf("err should be nil: %s", err.Error()) + } +} + +func TestRuleListItemListsGetListItemsWithOptionalParams(t *testing.T) { + t.Skip("skipped: tests are disabled for the time being") + baseURL := "http://localhost:4010" + if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { + baseURL = envURL + } + if !testutil.CheckTestServer(t, baseURL) { + return + } + client := cloudflare.NewClient( + option.WithBaseURL(baseURL), + option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), + option.WithAPIEmail("dev@cloudflare.com"), + option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), + option.WithUserServiceKey("My User Service Key"), + ) + _, err := client.Rules.Lists.Items.ListsGetListItems( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "2c0fc9fa937b11eaa1b71c4d701ab86e", + cloudflare.RuleListItemListsGetListItemsParams{ + Cursor: cloudflare.F("zzz"), + PerPage: cloudflare.F(int64(1)), + Search: cloudflare.F("1.1.1."), + }, + ) + if err != nil { + var apierr *cloudflare.Error + if errors.As(err, &apierr) { + t.Log(string(apierr.DumpRequest(true))) + } + t.Fatalf("err should be nil: %s", err.Error()) + } +} + +func TestRuleListItemListsUpdateAllListItems(t *testing.T) { + t.Skip("skipped: tests are disabled for the time being") + baseURL := "http://localhost:4010" + if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { + baseURL = envURL + } + if !testutil.CheckTestServer(t, baseURL) { + return + } + client := cloudflare.NewClient( + option.WithBaseURL(baseURL), + option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), + option.WithAPIEmail("dev@cloudflare.com"), + option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), + option.WithUserServiceKey("My User Service Key"), + ) + _, err := client.Rules.Lists.Items.ListsUpdateAllListItems( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "2c0fc9fa937b11eaa1b71c4d701ab86e", + cloudflare.RuleListItemListsUpdateAllListItemsParams{ + Body: cloudflare.F([]cloudflare.RuleListItemListsUpdateAllListItemsParamsBody{{ + Asn: cloudflare.F(int64(5567)), + Comment: cloudflare.F("Private IP address"), + Hostname: cloudflare.F(cloudflare.RuleListItemListsUpdateAllListItemsParamsBodyHostname{ + URLHostname: cloudflare.F("example.com"), + }), + IP: cloudflare.F("10.0.0.1"), + Redirect: cloudflare.F(cloudflare.RuleListItemListsUpdateAllListItemsParamsBodyRedirect{ + IncludeSubdomains: cloudflare.F(true), + PreservePathSuffix: cloudflare.F(true), + PreserveQueryString: cloudflare.F(true), + SourceURL: cloudflare.F("example.com/arch"), + StatusCode: cloudflare.F(cloudflare.RuleListItemListsUpdateAllListItemsParamsBodyRedirectStatusCode301), + SubpathMatching: cloudflare.F(true), + TargetURL: cloudflare.F("https://archlinux.org/"), + }), + }, { + Asn: cloudflare.F(int64(5567)), + Comment: cloudflare.F("Private IP address"), + Hostname: cloudflare.F(cloudflare.RuleListItemListsUpdateAllListItemsParamsBodyHostname{ + URLHostname: cloudflare.F("example.com"), + }), + IP: cloudflare.F("10.0.0.1"), + Redirect: cloudflare.F(cloudflare.RuleListItemListsUpdateAllListItemsParamsBodyRedirect{ + IncludeSubdomains: cloudflare.F(true), + PreservePathSuffix: cloudflare.F(true), + PreserveQueryString: cloudflare.F(true), + SourceURL: cloudflare.F("example.com/arch"), + StatusCode: cloudflare.F(cloudflare.RuleListItemListsUpdateAllListItemsParamsBodyRedirectStatusCode301), + SubpathMatching: cloudflare.F(true), + TargetURL: cloudflare.F("https://archlinux.org/"), + }), + }, { + Asn: cloudflare.F(int64(5567)), + Comment: cloudflare.F("Private IP address"), + Hostname: cloudflare.F(cloudflare.RuleListItemListsUpdateAllListItemsParamsBodyHostname{ + URLHostname: cloudflare.F("example.com"), + }), + IP: cloudflare.F("10.0.0.1"), + Redirect: cloudflare.F(cloudflare.RuleListItemListsUpdateAllListItemsParamsBodyRedirect{ + IncludeSubdomains: cloudflare.F(true), + PreservePathSuffix: cloudflare.F(true), + PreserveQueryString: cloudflare.F(true), + SourceURL: cloudflare.F("example.com/arch"), + StatusCode: cloudflare.F(cloudflare.RuleListItemListsUpdateAllListItemsParamsBodyRedirectStatusCode301), + SubpathMatching: cloudflare.F(true), + TargetURL: cloudflare.F("https://archlinux.org/"), + }), + }}), + }, + ) + if err != nil { + var apierr *cloudflare.Error + if errors.As(err, &apierr) { + t.Log(string(apierr.DumpRequest(true))) + } + t.Fatalf("err should be nil: %s", err.Error()) + } +}